Skip to content

Commit 5e42991

Browse files
committed
docs(options): update appContext for file import
1 parent 742547c commit 5e42991

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

docs/content/1.v2/1.guide/1.options.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,21 @@ Return value is the `config`. `async` is supported.
159159
| `async` | `Boolean` | | Components are loaded asynchronously. If there is more than one entry the async will lead to unwanted webpack chunk splitting. | `false` |
160160
| `path` | `String` | | Path to the component to be called by the tag. | `false` |
161161
| `options` | `Function`, `Object` | | Options from custom-element. <br>[Learn more](https://github.com/karol-f/vue-custom-element#options) about `vue-custom-element` options. | `undefined` |
162-
| `appContext` | `Function` | | Function call to extend the Vue app. Example: Plugin registration of `vuetify`, `pinia`, `vue-router`, ... | `undefined` |
162+
| `appContext` | `String`, `Function` | | File Reference or Function call to extend the Vue app. Example: Plugin registration of `vuetify`, `pinia`, `vue-router`, ... | `undefined` |
163163
| `css` | `String` | | Can be used to inject CSS into the element. | `undefined` |
164164
| `slotContent` | `String` | | Default slot content for generated html entry output. | `undefined` |
165165

166+
#### Example appContext config file
167+
168+
```js
169+
export default function (Vue) {
170+
// Customize Vue App here
171+
// e.g. Vue.component('my-component', MyComponent) or Vue.use(MyPlugin)
172+
173+
console.log('Vue App', Vue);
174+
}
175+
```
176+
166177
#### Important
167178

168179
1. You can set as `object` or when using functions in options, use `function`.
@@ -200,12 +211,28 @@ Return value is the `config`. `async` is supported.
200211
}
201212
```
202213

203-
2. You can extend the Vue app to install plugins, for example. (e.g. `vuetify`, `pinia`, `vue-18n`, `vue-router`)
214+
2. You can customize the Vue app to install plugins, for example. (e.g. `vuetify`, `pinia`, `vue-18n`, `vue-router`)
204215

205216
```js
206217
{
207218
name: 'ComponentAppExample',
208219
tags: [
220+
// Recommended to control appContext via config file.
221+
{
222+
async: true,
223+
name: 'CustomElementAppExample',
224+
path: '@/components/apps/AppExample',
225+
options: {
226+
props: {
227+
'prop1': 'Value 1',
228+
'prop2': 'Value 2'
229+
}
230+
},
231+
appContext: '@/components/apps/AppExample.appContext.js',
232+
slotContent: '<div>Slot Content!</div>'
233+
},
234+
// appContext can also be defined by function, this is copied to the entry by stringify.
235+
// Beware: function loses the scope to `nuxt.config`.
209236
{
210237
async: true,
211238
name: 'CustomElementAppExample',
@@ -246,10 +273,7 @@ Return value is the `config`. `async` is supported.
246273
options: {
247274
props: ['prop1', 'prop2'],
248275
},
249-
appContext(Vue) {
250-
console.log('Vue App', Vue);
251-
// usage for Vue.use…
252-
}
276+
appContext: 'Path to ComponentOne Config',
253277
}
254278
]
255279
},
@@ -264,7 +288,8 @@ Return value is the `config`. `async` is supported.
264288
'prop1': 'Value 1',
265289
'prop2': 'Value 2'
266290
}
267-
}
291+
},
292+
appContext: 'Path to ComponentTwo Config',
268293
}
269294
]
270295
},
@@ -279,7 +304,8 @@ Return value is the `config`. `async` is supported.
279304
path: 'Path to ComponentOne',
280305
options: {
281306
props: ['prop1', 'prop2']
282-
}
307+
},
308+
appContext: 'Path to ComponentOne Config',
283309
},
284310
{
285311
async: true,

0 commit comments

Comments
 (0)