标签:rect vue-cli extension line match copy gem remove directly
今天,无意打开vue-cli 3.0 UI控制台
闲来无事,看看了源码学到一手组件的动态加载,分享大家
/** * We register all the components so future cli-ui plugins * could use them directly */ import Vue from ‘vue‘ // https://webpack.js.org/guides/dependency-management/#require-context const requireComponent = require.context(‘./components‘, true, /[a-z0-9]+\.(jsx?|vue)$/i) // For each matching file name... requireComponent.keys().forEach(fileName => { const componentConfig = requireComponent(fileName) const componentName = fileName .substr(fileName.lastIndexOf(‘/‘) + 1) // Remove the file extension from the end .replace(/\.\w+$/, ‘‘) // Globally register the component Vue.component(componentName, componentConfig.default || componentConfig) }) © 2020 GitHub, Inc.
标签:rect vue-cli extension line match copy gem remove directly
原文地址:https://www.cnblogs.com/tylz/p/12186539.html