class 共有三种使用方法--字符串、数组、对象(对象里需要是class 具体值,不能是变量)
附代码:
<template>
<div>
<div :class="oneClass">测试111</div>
<div :class="{span1: true, span2: false}">样式</div>
<div :class="[oneClass, 'span2']">样式</div>
</div>
</template>
<script>
export default {
data () {
return {
oneClass: 'span1',
width: '200px'
}
}
}
</script>
<style lang="less" >
.span1{
color: red;
}
.span2{
background: green;
}
</style>