新建一个定义组件的js配置文件
//引入组件模块
import Addapproval from './Addapproval' //审批人
import Submit from './Submit' //确认提交按钮
import Addimg from './Addimg' //添加图片
import Selectgroup from './Selectgroup' //请假
import Ordinarybtn from './Ordinarybtn' //普通按钮
import Textarea from './Textarea' //textarea
import Textinput from './Textinput' //input
import ChooseDate from './ChooseDate' //时间选择
import Addotherfiles from './Addotherfiles' //添加附件
import AddccAapproval from './AddccAapproval' //抄送人
import Actionsheet from './Actionsheet' //actionsheet
import GroupChooseDate from './GroupChooseDate' //组合日期
import GroupTextarea from './GroupTextarea' //组合文本框
import SelfAddApproval from './SelfAddApproval' //添加抄送人
import Group from './Group' //组合组件
import GroupInput from './GroupInput'
import GroupSelect from './GroupSelect'
//存储引入的组件,用于注册组件
let compontentArr = [Addapproval,Submit,Addimg,Selectgroup,Ordinarybtn,Textarea,Textinput,
ChooseDate,Addotherfiles,AddccAapproval,Actionsheet, GroupChooseDate,GroupTextarea,SelfAddApproval,
Group,GroupInput,GroupSelect];
const Compontents = {
install:function (Vue) {
compontentArr.forEach(function (comItem) {//将引入的组件公用化
Vue.component(comItem.name,comItem)
})
}
};
export default Compontents
在main.js中注册组件全局使用
//引入自定义组件
import subgroup from './components/subgroup'//或者 import subgroup from './components/subgroup/index.js'
Vue.use(subgroup);