vue公共元件批量註冊引入

2021-09-21 01:42:22 字數 586 閱讀 5415

乙個vue檔案就是乙個元件,有些元件在專案中經常用到,每個頁面引入太麻煩, 可以新建乙個檔案批量引入註冊,這樣**好管理

新建乙個select js檔案裡面批量引入元件註冊再匯出

import searchselect from '../components/common/searchselect.vue';

import selectpub from '../components/common/selectpub.vue';

import picker_tade_w from '../components/common/date_ril.vue';

import selectmorepub from '../components/common/selectmorepub.vue';

import selectarea from '@/components/common/selectarea'

export default (vue)=>

main.js引入

import select from '@/js/select'

vue.use(select);

批量註冊vue區域性元件

昨天突然收到通知,說要做乙個支付的後台管理系統,其中有一部分是要設定各種支付的配置引數,每種支付方式的配置引數都是不一樣的,所以其實是可以看成乙個個單獨的元件,然後組合成乙個頁面了。最基礎的自然是依次匯入各個子元件,然後在 components 屬性中進行宣告,之後才能在模板中進行使用,再進行各種引...

vue註冊公共多個元件的方法

檔案目錄如下 commencomponents 資料夾下 index.js 如下 一次引入終身受用 require.context 引數的意義 arg1.在 找 arg2.是否要找子集 arg3.以什麼為規則來找 const requirecomponent require.context true...

vue 公用頁面引用 vue引入公共元件及js

一 引入全域性js 1.commonfunctions檔案中新建common.js裡面寫上想全域性呼叫的方法 2.main.js中importcommon from commonfunctions common.js 引入檔案 vue.prototype.common common 掛載到原形上 3...