安裝
npm install vue
引用
<script type="text/javascript" src="./node_modules/vue/dist/vue.js"></script>
新建vue對象
var x = new Vue({
el: '#app',
data: {
msg: '黃瓜',
str: 'hello'
},
template: ''
})
{{}} 引用
<div id="app">
<h2>{{msg}}</h2>
<h3>{{1 + 1}}</h3>
</div>
代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<h2>{{msg}}</h2>
<h3>{{1 + 1}}</h3>
</div>
<script type="text/javascript" src="./node_modules/vue/dist/vue.js"></script>
<script type="text/javascript">
var x = new Vue({
el: '#app',
data: {
msg: '黃瓜',
str: 'hello'
},
template: ''
})
console.log(x.$el)
console.log(x.$data)
</script>
</body>
</html>