Mass registering global components
Import top level components and export them as an Array:
|
1 2 3 4 5 6 7 8 9 10 11 |
// File: /components/index.js import Component1 from './Component1.vue'; import Component2 from './Component2.vue'; import Component3 from './Component3.vue'; export default [ Component1, Component2, Component3 ]; |
Then in main.js we loop through the components and register them globally:
|
1 2 3 4 5 6 7 8 |
import Vue from 'vue'; import globalComponents from './components'; globalComponents.forEach(component => { Vue.component(component.name, component); }); // load Vue |
Useful Vuejs libraries
https://cdn.jsdelivr.net/npm/v-mask/dist/v-mask.min.jsĀ can be used for phone and zip code masks to prevent bad input. Also works with Element UI. Just include via cdn and then can be used as a directive i.e. :
|
1 |
<el-input v-model="phone" v-mask="'(###) ###-####'" ></el-input> |