<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="js/vue.js"></script> </head> <body> <div id="app"></div> <script> const users = Vue.extend({ template : ` <div> <h1>哈哈哈</h1> </div> `, mounted() { // 这里的this是VueComponent实例对象 // users是什么呢?是一个全新的构造函数VC构造函数 console.log(this === users); } }); const vm = new Vue({ el : "#app", template : `<users></users>`, components : {users}, mounted(){ // 这个this是VUE实例对象 console.log(this); } }); function test() { var Sub = function User(){ this.name = 'admin'; } return Sub; } let a = test(); console.log(a); let b = test(); console.log(b); console.log(a === b); </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app"></div>
<script>
const users = Vue.extend({
template : `
<div>
<h1>哈哈哈</h1>
</div>
`,
mounted()
{
// 这里的this是VueComponent实例对象
// users是什么呢?是一个全新的构造函数VC构造函数
console.log(this === users);
}
});
const vm = new Vue({
el : "#app",
template : `<users></users>`,
components : {users},
mounted(){
// 这个this是VUE实例对象
console.log(this);
}
});
function test()
{
var Sub = function User(){
this.name = 'admin';
}
return Sub;
}
let a = test();
console.log(a);
let b = test();
console.log(b);
console.log(a === b);
</script>
</body>
</html>
VUE框架VM对象与VC对象------VUE框架
最新推荐文章于 2024-01-16 12:32:23 发布