Vue main.js 文件中全局组件注册部分
在 \src\components\index.js 文件中export组件
import HeaderList from './HeaderList' import HeaderMenu from './HeaderMenu' import HeaderPatient from './HeaderPatient' import ExitUser from './ExitUser' import TreePanel from './VueTree' import TreeTable from './pc/TreeTable' import TinymceText from './Tinymce' export default { HeaderList, HeaderMenu, HeaderPatient, ExitUser, TreePanel, TreeTable, TinymceText, }
main.js中修改如下:
首字母替换成大写,加上小写字母v开头。
import components from './components/' //加载公共组件 Object.keys(components).forEach((key) => { var name = key.replace(/(\w)/, (v) => v.toUpperCase()) Vue.component('v'+name, components[key]) })