v-bind:属性名 简写:属性名
v-bind:style=””
v-bind:classv-on:事件名 简写:事件名
v-on:click
v-on:input
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue编程</title>
<!-- <script src="https://unpkg.com/vue@3"></script> -->
<script src="vue.js"></script>
<style>
.p {
padding: 1px;
}
.m {
margin: 10px;
}
.b {
border: 1px solid #343434;
}
.br {
border-radius: 10px;
}
.bag {
background-color: aqua;
}
.bag2 {
background-color: blanchedalmond;
}
.c {
color: blueviolet;
}
</style>
</head>
<body>
<div id="app">
<div v-bind:style="red" v-text="message"></div>
<div v-bind:style={color:color,backgroundColor:bgc} v-text="message2"></div>
<div v-bind:style=[mycolor,mybgc] v-text="message3"></div>
<div v-bind:class="'c'" v-text="message4"></div>
<div v-bind:class="moreclass" v-text="message5"></div>
<div v-bind:class={c:true,bag2:true} v-text="message6"></div>
<div v-bind:class=[mycolor2,mybgc2] v-text="message7"></div>
<div v-bind:class=['bag2','b'] v-text="message8"></div>
<div>
<input type="text" value="测试" v-on:input="comment=$event.target.value" />
<span>{{comment}}</span>
</div>
<div>
<input type="text" v-model.lazy="comment2" />
<span>{{comment2}}</span>
</div>
</div>
<script>
const { createApp } = Vue
createApp({
data() {
return {
message: 'message1 Hello Vue66!',
red: 'color:red',
message2: 'message2 绑定样式,字面量形式',
color: 'blue',
bgc: 'green',
message3: ' message3 绑定样式,数组形式',
mycolor: 'color:red',
mybgc: 'background-color:wheat',
message4: ' message4 绑定class,给样式做绑定',
message5: ' message5 绑定class,用变量名,给样式做绑定',
moreclass: 'c bag',
message6: 'message6 绑定class,用字面量的形式,来给类名做判断,真就赋值,假就不给赋值',
message7: 'message7 绑定class,数组里面存的是变量,在变量中存放多个样式的名字',
mycolor2: 'c br b',
mybgc2: 'bag2',
message8: 'message8 绑定class,数组里面存的是样式名,直接显示,不再调用',
comment: null,
comment2: '我这里做延时',
}
}
}).mount('#app')
</script>
</body>
</html>