在下面的代码中,getWidth
事件处理程序(在methods
对象中定义)更新data.width
属性。随着它的更新,该变量width
应该在 VueJS 的 Chrome 插件中实时显示。
但是,该实时更新并未显示在 Vue DevTools 中。我不确定代码是否有问题或者我做错了什么。插件不是问题,因为我也在 Firefox 中进行了测试。
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;
}
}
})