官方文档:状态驱动的动态 CSS
编写一个组件:
代码语言:javascript复制<template>
<div class="ruben">
<p>You clicked {{ count }} times</p>
<button @click="increment">Click me</button>
</div>
</template>
<script>
export default {
data() {
return {
count: 1
}
},
methods: {
increment() {
this.count
}
}
}
</script>
<style scoped>
.ruben {
transform: scale(v-bind(count));
}
</style>
测试: