<!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>
<!-- 要引入vue.min.js文件 -->
<script src="./vue3.js"></script>
</head>
<body>
<div id="counter">
<div>
vue的语法,告诉vue,这里面放了一个变量
{{num}}
</div>
</div>
<script>
const Counter = {
data: function () {
return {
num: 0,
name: "张三"
}
}
}
// //创建应用,将配置对象传入
// Vue.createApp(Counter)
//创建应用,将配置对象传入,通过mount对象进行挂载,和html中dom元素相关联 (源码10789行)
Vue.createApp(Counter).mount("#counter");
let app = Vue.createApp(Counter).mount("#counter");//可继续链式调用
console.log(app);//返回值还是一个对象,
app.num =4 //双向绑定的
</script>
</body>
</html>