index.js 919 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3
import Vue from 'vue'

import baseMixin from 'uni-mixins/base'
4
import animation from 'uni-mixins/animation'
fxy060608's avatar
fxy060608 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

const requireComponents = [
  // baseComponents
  require.context('./', true, /index\.vue$/),
  require.context('../../../platforms/' + __PLATFORM__ + '/view/components', true, /index\.vue$/)
]

requireComponents.forEach((components, index) => {
  components.keys().forEach(fileName => {
    // 获取组件配置
    const componentModule = components(fileName)

    const componentConfig = componentModule.default || componentModule

    componentConfig.mixins = componentConfig.mixins ? [].concat(baseMixin, componentConfig.mixins) : [baseMixin]

21 22
    componentConfig.mixins.push(animation)

fxy060608's avatar
init v3  
fxy060608 已提交
23 24 25
    componentConfig.name = 'VUni' + componentConfig.name

    componentConfig.isReserved = true
fxy060608's avatar
fxy060608 已提交
26 27 28 29

    // 全局注册组件
    Vue.component(componentConfig.name, componentConfig)
  })
30
})