Vue's template syntax
Assignment, there are three commonly used, but you must know the difference between them.
Knowledge points:
- String splicing
- v-text
- v-html
As for v-text, it directly assigns the bound data.
For v-html, if the value has a tag, the effect of the tag will be displayed.
<!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 + ' LEE'}}
<div v-text="name + ' LEE'"></div>
<div v-html="name + ' LWW'"></div>
</div>
<script>
var vm = new Vue({
el: "#app",
data: {
name: "Dell"
// name: "<h1>Dell</h1>"
}
})
</script>
</body>
</html>