<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Hello Vue</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* 刷新的时候不显示 */
[v-cloak]{
display: none;
}
</style>
</head>
<body>
<div id="main">
<!-- <h2 v-cloak :title="title">{{msg}}</h2> -->
<!-- 简化版绑定属性 -->
<h2 v-cloak :title="title">{{msg}}</h2>
<!-- <input type="button" value="点我" v-on:click="function1"/> -->
<!-- 简化版绑定事件 -->
<input type="button" value="点我" @click="function1"/>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var vm = new Vue({
// 要用哪一个div 即V层
el : '#main',
// 数据 即M层
data : {
msg:'hello vue',
title:'我是title',
},
// 方法 函数
methods : {
function1:function(){
alert(this.msg+"!!!!")
}
},
})
</script>
</body>
</html>
vue教程:https://cn.vuejs.org/v2/guide/
51cto:http://edu.51cto.com/center/course/lesson/index?id=290722