美文网首页
vue-复用混合

vue-复用混合

作者: 一点金光 | 来源:发表于2019-08-22 13:02 被阅读0次

混合对象

概念

一个对象。可以包含任意组件选项,用于分发 Vue 组件中可复用的功能。减少了代码的书写。

定义

// 定义
var myMixin = {
  created: function () {
    this.hello()
  },
  methods: {
    hello: function () {
      console.log('hello from mixin!')
    }
  }
}
// 使用
var Component = Vue.extend({
  mixins: [myMixin]
})
var component = new Component() // => "hello from mixin!"

选项合并

条件

策略

全局混合

相关文章

网友评论

      本文标题:vue-复用混合

      本文链接:https://www.haomeiwen.com/subject/cjkneftx.html