网站建设自查维护报告,周村网站制作首选公司,南山商城网站建设哪家技术好,电子商务网站平台建设前景展望!--绑定样式#xff1a;1. class 样式写法#xff1a;:classxxx xxx 可以是字符串、对象、数组字符串写法适用于#xff1a;类名不确定#xff0c;要动态获取对象写法适用于#xff1a;要绑定多个样式#xff0c;个数不确定#xff0c;名字也不确定数组…!--绑定样式1. class 样式写法:classxxx xxx 可以是字符串、对象、数组字符串写法适用于类名不确定要动态获取对象写法适用于要绑定多个样式个数不确定名字也不确定数组写法适用于要绑定多个样式个数不确定名字不确定也不确定用不用2. style 样式:style{fontSize: xxx} 其中 xxx 是动态值:style[a, b] 其中a b 是样式对象
--
div idroot!-- 绑定 class 样式 -- 字符串写法适用于样式的类名不确定需要动态指定 --div classbasic :classmoon clickdoChangeColor/div!-- 绑定 class 样式 -- 数组写法适用于要绑定的样式个数不确定、名字也不确定 --div classbasic :classmoonArr/div!-- 绑定 class 样式 -- 对象写法适用于要绑定的样式个数确定、名字也确定但要动态绑定决定用不用 --div classbasic :classmoonObj/div!-- 绑定 style 样式 -- 对象写法 --div classbasic :style[styleObj]/div!-- 绑定 style 样式 -- 数组写法 --div classbasic :style[styleObj, styleObj2]/div!-- 绑定 style 样式 -- 数组中嵌套对象写法 --div classbasic :stylestyleObj3/div/div
script src../js/vue.js/script
scriptVue.config.productionTip false;const vm new Vue({el: #root,data: {moon: beautiful1,moonArr: [beautiful1, beautiful2, beautiful3],moonObj: {beautiful1: false,beautiful2: true,beautiful3: false,},styleObj: {backgroundColor: red},styleObj2: {borderRadius: 50%},styleObj3: [{backgroundColor: red},{borderRadius: 50%},]},methods: {doChangeColor() {let index Math.floor(Math.random() * 3 1);this.moon beautiful index;}}})
/script