v-bind Vue的指令 动态绑定为属性赋值
语法: v-bind:属性(参数)=" 变量值"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../js/vue.js"></script>
<style>
.red {
color: blue;
}
.font {
font-size: 40px;
}
</style>
</head>
<body>
<div v-html="rawHtml" id="app" v-bind:class="{red:isRed,font:isFont}"></div>
<div id="app1" v-bind:style="{color:color,fontSize:fontSize}">listen and point</div>
<script>
var vm = new Vue({
el: "#app",
data: {
rawHtml: "<span>hello world111</span>",
isRed:true,
isFont:true,
}
});
var vm1 = new Vue({
el: "#app1",
data: {
color: "red",
fontSize: '50px',
}
});
</script>
</body>
</html>
来源:https://www.cnblogs.com/kukai/p/12382340.html