In the code below, the getWidth event handler (defined in the methods object) updates the data.width property. As it updates, the variable width should be shown live in VueJS's Chrome addon.
However, that live update doesn't show up in the Vue DevTools. I'm not sure if there is something wrong with the code or what am I doing wrong. The add-on isn't a problem since I've tested in Firefox too.
HTML
<div id="app">
<p :style="{width: 200 + 'px'}" class="box">{{msg}}</p>
<button v-on:click="getWidth">New Width</button>
</div>
JS
new Vue({
el: '#app',
data: {
msg: 'Test Message',
mywidth: ''
},
methods: {
getWidth: function(){
this.mywidth = 20 * 2;
}
}
})
()isn't required to execute the method. However if you there's a variable you'd want to pass to the method then you'd pass that using()something as(width).mywidthis related withwidth?