mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
docs: add example of 'alphabetical' plugin numbering (#20930)
This commit is contained in:
parent
891ba880e2
commit
4d0c9bf679
@ -67,20 +67,24 @@ If you are using an object-syntax plugin, the properties may be statically analy
|
||||
|
||||
## Plugin Registration Order
|
||||
|
||||
You can control the order in which plugins are registered by prefixing a number to the file names.
|
||||
You can control the order in which plugins are registered by prefixing with 'alphabetical' numbering to the file names.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
plugins/
|
||||
| - 1.myPlugin.ts
|
||||
| - 2.myOtherPlugin.ts
|
||||
| - 01.myPlugin.ts
|
||||
| - 02.myOtherPlugin.ts
|
||||
```
|
||||
|
||||
In this example, `2.myOtherPlugin.ts` will be able to access anything that was injected by `1.myPlugin.ts`.
|
||||
In this example, `02.myOtherPlugin.ts` will be able to access anything that was injected by `01.myPlugin.ts`.
|
||||
|
||||
This is useful in situations where you have a plugin that depends on another plugin.
|
||||
|
||||
::alert{type=info icon=💡}
|
||||
In case you're new to 'alphabetical' numbering, remember that filenames are sorted as strings, not as numeric values. For example, `10.myPlugin.ts` would come before `2.myOtherPlugin.ts`. This is why the example prefixes single digit numbers with `0`.
|
||||
::
|
||||
|
||||
## Using Composables Within Plugins
|
||||
|
||||
You can use [composables](/docs/guide/directory-structure/composables) within Nuxt plugins:
|
||||
|
Loading…
Reference in New Issue
Block a user