前端前端
fabric
算法
jsBlock
styleBlock
svgBlock
工具其他
Vue、React相关
webgl
GitHub
fabric
算法
jsBlock
styleBlock
svgBlock
工具其他
Vue、React相关
webgl
GitHub
  • 1_1_nextjs项目开发
  • 1_2_nextjs项目部署
  • React
  • React使用中遇到的一些问题
  • React构建create-react-app简单说明
  • ubuntu使用
  • vue.init
  • vue.use
  • vuex源码解析
  • Vue使用中遇到的一些问题
  • vue梳理
  • watcher&&dep
  • 代码片段
  • 打包
  • 简单双向绑定
  • 纯函数

vue.init

mergeOptions

  • Vue 实例 绑定一些方法属性 op1
  • new Vue传参 op2
  • Vue 构造方法 绑定一些方法属性 op3

Vue init方法里 $options = {...op3, ...op2, ...op1}

vm.$options = mergeOptions(
  resolveConstructorOptions(vm.constructor),
  options || {},
  vm
)

resolveConstructorOptions

直接new 的返回options, Vue.extend 父类+自身options

// 测试
var Profile = Vue.extend({
  template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>'
})
Vue.mixin({
  data: function () {
    return {
      firstName: 'Walter',
      lastName: 'White',
      alias: 'Heisenberg'
    }
  }
})
new Profile().$mount('#example')

initProxy

proxy 测试环境警告,未定义的属性出现会警告。 给vm包了一个Proxy并挂在vm._renderProxy上,这样当你用‘test’ in vm._renderProxy去测试vm上是否有此test属性时就会触发Proxy中的has,产生没有属性时的提示效果

if (process.env.NODE_ENV !== 'production') {
  initProxy(vm)
} else {
  vm._renderProxy = vm
}

vm._renderProxy = new Proxy(vm, handlers)
Edit this page
最近更新:: 2021/5/26 17:52
Contributors: wuhui
Prev
ubuntu使用
Next
vue.use