index.js 2.61 KB
// // 导入颜色选择器组件
// import GLExternal from './External'
// import GLButton from './Button'
// import GLDialog from './Dialog'
// import GLTable from './Table'
// import '@/plugins/element.js'
// import '@/theme/theme.scss'
// import { Table, TableColumn, Popover } from 'element-ui'
// // 存储组件列表
// const components = [GLExternal, GLButton, GLDialog, GLTable, Table, TableColumn, Popover]
// // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
// const install = function(Vue) {
//   // 判断是否安装
//   if (install.installed) return
//   // 遍历注册全局组件
//   components.map(component => Vue.component(component.name, component))
// }
// // 判断是否是直接引入文件
// if (typeof window !== 'undefined' && window.Vue) {
//   install(window.Vue)
// }
// export { GLExternal, GLButton, GLDialog, GLTable, Table, TableColumn ,Popover}
// export default {
//   // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
//   install
// }

/***
 * new line
 */
// 导入颜色选择器组件
// import '@/plugins/element.js'
import {Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip} from '@/plugins/element.js'
import '@/theme/theme.scss'

// test 组件
import TestComp from './TestComp'

import GLExternal from './External'
import GLButton from './Button'
import GLDialog from './Dialog'
import GLTable from './Table'
import GLFooter from './Footer'
// 一次性注册所有的过滤器  本地测试
import filters from '@/filters'

//el原始组件
const ElComponent =[Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip]

// 存储组件列表
const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter].concat(ElComponent)
// console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册

const install = function(Vue) {
  // 注册全局过滤器(一次性注册)
  Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
  })
  // 判断是否安装
  if (install.installed) return
  // 遍历注册全局组件
  components.map(component => Vue.component(component.name, component))
}
// 判断是否是直接引入文件
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
  install,
  ...ElComponent,
  TestComp,
  GLExternal,
  GLButton,
  GLDialog,
  GLTable,
  GLFooter
}