导入vue.js
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
创建一个标签
<div id="app">
{{message}}
</div>
接管标签内容,创建vue实例
<script type="text/javascript">
var app=new Vue({
el: '#app',
data: {
message: 'hello world'
}
})
</script>
完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<div id="app">
{{message}}
</div>
</body>
<script type="text/javascript">
var app=new Vue({
el: '#app',
data: {
message: 'hello world'
}
})
</script>
</html>
效果图
数据驱动的web界面