In VueJS, I found that it's not possible to pass arguments to a computed property from methods object. I'd would like to know the logic behind this.
Is there a way to pass arguments to computed properties from methods object.
Something like this:
HTML
<div id="app">
<p>Computed Property width: {{ width }}</p>
<p>Changed Width: {{changed}}</p>
<button @click="changeWidth">Get new Width</button>
</div>
JS
new Vue({
el: '#app',
data: {
msg: 'Test Message',
changed: 0
},
computed: {
width: function(factor){
return 20 * factor;
}
},
methods: {
changeWidth: function(){
this.changed += 20 * this.width(5);
}
}
})