Skip to content

Commit fdf0316

Browse files
authored
Remove style guide recommendation on global base components (#2949)
Right now official Vue Style Guide suggests you use global components when you deal with base components. This can lead to confusion with new developers coming to a project, IDE assistance and testing. This PR removes this recommendation so it's always obvious how components are imported.
1 parent 3c39ec1 commit fdf0316

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

src/v2/style-guide/index.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -771,22 +771,6 @@ Some advantages of this convention:
771771

772772
- Since component names should always be multi-word, this convention prevents you from having to choose an arbitrary prefix for simple component wrappers (e.g. `MyButton`, `VueButton`).
773773

774-
- Since these components are so frequently used, you may want to simply make them global instead of importing them everywhere. A prefix makes this possible with Webpack:
775-
776-
``` js
777-
var requireComponent = require.context("./src", true, /Base[A-Z]\w+\.(vue|js)$/)
778-
requireComponent.keys().forEach(function (fileName) {
779-
var baseComponentConfig = requireComponent(fileName)
780-
baseComponentConfig = baseComponentConfig.default || baseComponentConfig
781-
var baseComponentName = baseComponentConfig.name || (
782-
fileName
783-
.replace(/^.+\//, '')
784-
.replace(/\.\w+$/, '')
785-
)
786-
Vue.component(baseComponentName, baseComponentConfig)
787-
})
788-
```
789-
790774
{% raw %}</details>{% endraw %}
791775

792776
{% raw %}<div class="style-example example-bad">{% endraw %}

0 commit comments

Comments
 (0)