You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't find any document about Automatic Global Registration of Base Components in Vue 3.x Component Registration documents.
i solved this problem using Vue 2.x document and made a little change:
// automatic register global componentimportupperFirstfrom"lodash/upperFirst";importcamelCasefrom"lodash/camelCase";constcreatedApp=createApp(App);constrequireComponent=require.context(// The relative path of the components folder"./components",// Whether or not to look in subfoldersfalse,// The regular expression used to match base component filenames/Base[A-Z]\w\.(vue|js)$/,);requireComponent.keys().forEach(fileName=>{// Get component configconstcomponentConfig=requireComponent(fileName);// Get PascalCase name of componentconstcomponentName=upperFirst(camelCase(// Gets the file name regardless of folder depthfileName.split("/").pop().replace(/\.\w$/,""),),);// Register component globallycreatedApp.component(componentName,// Look for the component options on `.default`, which will// exist if the component was exported with `export default`,// otherwise fall back to module's root.componentConfig.default||componentConfig,);});
Add it to Vue 3.x document, please
The text was updated successfully, but these errors were encountered:
I can't find any document about Automatic Global Registration of Base Components in Vue 3.x Component Registration documents.
i solved this problem using Vue 2.x document and made a little change:
Add it to Vue 3.x document, please
The text was updated successfully, but these errors were encountered: