设为首页 加入收藏

TOP

【js】vue 2.5.1 源码学习 (三) Vue.extend 和 data的合并策略(三)
2019-09-17 19:09:55 】 浏览:58
Tags:vue 2.5.1 源码 学习 Vue.extend data 合并 策略
203 function initExend(Vue){ 204 Vue.extend = function(extendOptions){ 205 extendOptions = extendOptions || {} // -----忘记写 206 var Super = this 207 var Child = function VueComponent() { 208 this._init(options) 209 } 210 Child.prototype = Object.create(Super.prototype) 211 Child.prototype.constructor = Child // 改变constructor 的指向 212 Child.options = mergeOptions(Super.options,extendOptions) 213 // 子类继承父类的静态方法。 214 Child.extend = Vue.extend 215 return Child 216 } 217 } 218 initExend(Vue) 219 return Vue 220 })
 1 <body>
 2     <div id="app">
 3         <huml></huml>
 4     </div>
 5     <script src="vue.js"></script>
 6     <!-- <script src="vue2.5.1.js"></script> -->
 7     <script type="text/java script">
 8         var componentA = {
 9             el: "#app"
10         }
11         var vm = new Vue({
12             el:"#app",
13             data: {
14                 message: "hello Vue",
15                 key: "wodow"
16             },
17             components:{
18                 huml: componentA
19             }
20             
21         })
22         // console.log(Vue)
23         var Parent = Vue.extend({
24             data: function() {}
25         })
26         var Child = Parent.extend({});
27         console.log(vm.$options)
28     </script>
29 </body>

以上仅个人在学习中的总结笔记,如有问题,请评论回复。

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇npm 下一篇前端基础之JavaScript_2

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目