admin管理员组文章数量:1316363
I'm trying out vuejs by following along with the laracasts series of webcasts on this. In , Jeffery Way has put the code in the / .
The initial setting is shown in the screenshot, before any plan is selected. I would like to set a default value in the button of "please select " (instead of "Downgrade") The button code is:
<span v-else>
<button @click="setActivePlan">
{{ isUpgrade ? 'Upgrade' : 'Downgrade' }}
</button>
How can I do this?
I'm trying out vuejs by following along with the laracasts series of webcasts on this. In https://laracasts./series/learning-vue-step-by-step/episodes/6, Jeffery Way has put the code in the http://jsfiddle/d4f27e5p/ .
The initial setting is shown in the screenshot, before any plan is selected. I would like to set a default value in the button of "please select " (instead of "Downgrade") The button code is:
<span v-else>
<button @click="setActivePlan">
{{ isUpgrade ? 'Upgrade' : 'Downgrade' }}
</button>
How can I do this?
Share Improve this question edited Jan 11, 2016 at 16:56 user1592380 asked Jan 11, 2016 at 16:35 user1592380user1592380 36.4k105 gold badges312 silver badges551 bronze badges1 Answer
Reset to default 5How about adding a puted property for the button text that includes the additional logic? Something like this:
buttonText: function() {
if(!this.active.name)
return "Please Select";
return this.isUpgrade ? 'Upgrade' : 'Downgrade';
}
Then the button would use this:
<span v-else>
<button @click="setActivePlan">
{{ buttonText }}
</button>
</span>
Here's an updated jsfiddle.
本文标签: javascriptSetting initial value for computed property with vuejsStack Overflow
版权声明:本文标题:javascript - Setting initial value for computed property with vuejs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742001209a2411048.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论