Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
挂载实例
<div class="app">
<p>用户名:{{username}}</p>
</div>
const app = Vue.createApp({
data(){
return{
username:'王老师',
};
},
}).mount('.app');
数据注入
console.log(app.username);
响应式
app.username = '张老师';
<p>用户名: <span v-text="username"></span></p>
<p>用户名: <span v-html="username"></span></p>
动态值
<p v-bind:style="{color:textColor,backgroundColor:bgc}">php</p>
行内样式对象
<p v-bind:style="[base,custom]">php123</p>
<p :class="{active: isActive}">hello 老师123</p>
<p :class="[mycolor,mybgc]">hello 老师456</p>
<script>
const app = Vue.createApp({
data(){
return{
//style: 'color:blue;',
textColor: 'blue',
bgc:'wheat',
base:{
border:'1px solid',
background:'#e0ff00'
},
custom:{
color:'white',
padding:'15px',
},
active: 'active',
isActive: true,
mycolor: 'active',
mybgc: 'bgc'
};
},
}).mount('.app');
</script>
<p>
<input type="text" @input="comment = $event.target.value " :value="comment">
<span>{{comment}}</span>
</p>