close
<div id="app">
<div class= "box" v-bind:class ="{rotate : color}"></div>
<hr>
<button class="btn btn-outline-primary" v-on:click="color = !color">選轉物件</button>
</div>
rorate = 要加的class name
color =屬性為false
點擊了 button 會讓color 變成true ,rotate就加上去了
跟jquery toggle class很像
<script>
var app = new Vue({
el: '#app',
data: {
red:'rotate',
color: false
},
});
</script>
文章標籤
全站熱搜
留言列表