示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mustache语法</title>
</head>
<body>
<div id="app">
<!-- mustache语法中,不仅仅可以直接写变量,也可以写简单的表达式-->
<h2>{{message}}</h2>
<h2>{{firstName + lastName}}</h2>
<h2>{{firstName + ' ' + lastName}}</h2>
<h2>{{firstName}} {{lastName}}</h2>
<h2>{{counter * 2}}</h2>
</div>
</body>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello',
firstName: 'kobe',
lastName: 'bryant',
counter: 100
}
})
</script>
</html>
结果: