一、差值表达式:
<!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>Document</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="app">
{{name}}
</div>
<script>
let vm =new Vue({
el:"#app",
data:{
name:"dell"
}
})
</script>
</body>
</html>
二、v-text语法向标签中赋值:
<!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>Document</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="app">
<div v-text="name"></div>
</div>
<script>
let vm =new Vue({
el:"#app",
data:{
name:"dell"
}
})
</script>
</body>
</html>
三、v-html
v-html 是让 该标签的 innerHtml方式进行赋值;
<!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>Document</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="app">
<div v-text="name"></div>
<div v-html="name"></div>
</div>
<script>
let vm =new Vue({
el:"#app",
data:{
name:"dell"
}
})
</script>
</body>
</html>
四、三者区别:
1、除了v-html能识别标签,其他2个不能识别标签。
2、3者内容中,都可以写js表达式
以上三种效果一样。