vue行内样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue 行内样式绑定</title>
<script src="./vue.js"></script>
</head>
<style type="text/css">
</style>
<body>
<div id="app">
<div :style="[styleobj,{fontSize:'20px'}]" @click="cli2">
content show
</div>
</div>
<script>
var vm = new Vue({
el: "#app",
data: {
styleobj: {
color: "black"
}
},
methods: {
cli2: function() {
this.styleobj.color = this.styleobj.color === "black" ? "red" : "black";
}
}
})
</script>
</body>
</html>