vue中动态绑定style值
以修改div背景颜色为例子:
<div
:style="{
width: '100px',
height: '200px',
background: bgm,
marginBottom: '20px',
}"
>
然后在data定义 bgm
data() {
return {
bgm: "lightblue",
active: "",
};
},
设置bgm
对应的值
bgm: "lightblue",
可根据业务需求修改所需要的 bgm
注意一点:
对于像 margin-bottom这样的样式,需要写成 marginBottom