Vue通过属性绑定为元素绑定style
程序员文章站
2022-03-03 09:16:59
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../js/vue-2.4.0 .js"></script>
<title>Document</title>
</head>
<body>
<!-- Vue通过属性绑定为元素绑定style -->
<div class="bind">
<h3 :class='classObject'>给元素绑定style对象</h3>
</div>
<style>
.colors{background-color: hotpink;}
.fontSize{font-size: 25px;}
.italic{font-style: italic;}
</style>
<script>
var f4 = new Vue({
el: '.bind',
data: {
flag: true,
classObject:{colors: true, fontSize: true, italic: false},
},
methods: {
}
})
</script>
</body>
</html>