Skip to content

Commit 2895684

Browse files
twickstromsdras
authored andcommitted
Globally register components example (#1959)
* Automatic Global Registration of Base Components example did not work if you wanted to include subfolders. This solution has been tested and confirmed. https://stackoverflow.com/questions/53676837/registering-components-globally-in-vuejs-in-subfolders/53678945#53678945 * Updated regex in global compnent registration code example to allow setting subfolder to true
1 parent fc6b292 commit 2895684

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/v2/guide/components-registration.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,15 @@ requireComponent.keys().forEach(fileName => {
207207
// Get PascalCase name of component
208208
const componentName = upperFirst(
209209
camelCase(
210-
// Strip the leading `./` and extension from the filename
211-
fileName.replace(/^\.\/(.*)\.\w+$/, '$1')
210+
// Gets the file name regardless of folder depth
211+
fileName
212+
.split('/')
213+
.pop()
214+
.replace(/\.\w+$/, '')
212215
)
213216
)
214217

218+
215219
// Register component globally
216220
Vue.component(
217221
componentName,

0 commit comments

Comments
 (0)