v-class
應用1
<div id="app">
<div class="box" :class="{'rotate':isTransform}"></div>
<hr>
<button class="btn btn-outline-primary" @click="isTransform = !isTransform">選轉物件</button>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
isTransform: false,
boxColor:false
},
});
</script>
<style>
.box {
transition: transform .5s;
}
.box.rotate {
transform: rotate(45deg)
}
</style>應用2:物件寫法
應用3:陣列寫法(動態加入類別)
綁定行內樣式
Last updated
Was this helpful?