VUE框架this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue3.js"></script>
</head>
<body>
<div id="app">
//单机
<p @click="foo('hulanxi1')">{{msg}}</p>
//双击
<p @dblick="foo('hulanxi2')">{{msg}}</p>
</div>
<script>
// 数据驱动界面
var vm = Vue.createApp({
data(){
return {
msg:"huchangxi",
books2: [
{title: "西游记", price: 199},
{title: "水浒传", price: 299},
{title: "三国演义", price: 399},
{title: "红楼梦", price: 499}
]
}
},
methods: {
foo(name){
this.msg = name;
console.log(this);// vm对象
var that = this;
this.books2.filter(function () {
console.log("::",this); // window对象
console.log(":::",that); // window对象
})
},
},
}).mount("#app")
</script>
</body>
</html>