new Vue({
el: '#app',
data: {
heig: 200,
wide: 100,
colorFT: '#CC',
colorBG: '#FF0000',
},
methods: {
changeStyle: function() {
this.heig = 300;
this.wide = 300;
}
}
});
<div id='app'>
<div v-bind:style="{'background':colorBG,'color':colorFT,'height':heig+'px','width':wide+'px'}">
123
</div>
<button v-on:click='changeStyle'>
测试
</button>
</div>