From 4f6bbe537a90e4e26ab80d401576549cea0a4c2b Mon Sep 17 00:00:00 2001 From: hang-up Date: Tue, 5 Dec 2023 17:14:15 -0500 Subject: [PATCH] Updated ecosystem-vue custom prop section. --- versioned_docs/version-5.x/ecosystem-vue.md | 68 +++++++++------------ versioned_docs/version-6.x/ecosystem-vue.md | 68 +++++++++------------ 2 files changed, 58 insertions(+), 78 deletions(-) diff --git a/versioned_docs/version-5.x/ecosystem-vue.md b/versioned_docs/version-5.x/ecosystem-vue.md index 9bf8ef5af..92d6872db 100644 --- a/versioned_docs/version-5.x/ecosystem-vue.md +++ b/versioned_docs/version-5.x/ecosystem-vue.md @@ -83,7 +83,15 @@ const vueLifecycles = singleSpaVue({ Vue, appOptions: { render(h) { - return h(App); + return h(App, { + props: { + // single-spa props are available on the "this" object. Forward them to your component as needed. + // https://single-spa.js.org/docs/building-applications#lifecycle-props + name: this.name, + mountParcel: this.mountParcel, + singleSpa: this.singleSpa, + } + }); }, router, }, @@ -132,35 +140,40 @@ export const unmount = vueLifecycles.unmount; ## Custom props -[Single-spa custom props](/docs/building-applications/#custom-props) can be passed to your root component like so: +[Single-spa custom props](/docs/building-applications/#custom-props) can be passed to your root component. In your application's entry file, add the props to your root component: + +### Vue 2 ```js -// main.js const vueLifecycles = singleSpaVue({ Vue, appOptions: { render(h) { return h(App, { - mountParcel: this.mountParcel, - otherProp: this.otherProp, + props: { + otherProp: this.otherProp, + }, }); }, - router, }, }); ``` +### Vue 3 -```vue -// App.vue - - +```js +const vueLifecycles = singleSpaVue({ + Vue, + appOptions: { + render(h) { + return h(App, { + // Notice that this is not within a props object! + otherProp: this.otherProp, + }); + }, + router, + }, +}); ``` ## Shared dependencies @@ -232,29 +245,6 @@ const vueLifecycles = singleSpaVue({ }); ``` -## Custom Props - -[single-spa custom props](/docs/building-applications#custom-props) are available in the `render()` function in your main file. They can be passed as custom props to your App component. - -```js -const vueLifecycles = singleSpaVue({ - Vue, - appOptions: { - render(h) { - return h(App, { - props: { - // single-spa props are available on the "this" object. Forward them to your component as needed. - // https://single-spa.js.org/docs/building-applications#lifecycle-props - name: this.name, - mountParcel: this.mountParcel, - singleSpa: this.singleSpa, - }, - }); - }, - }, -}); -``` - ## Parcels ### Creating a parcel diff --git a/versioned_docs/version-6.x/ecosystem-vue.md b/versioned_docs/version-6.x/ecosystem-vue.md index 9bf8ef5af..92d6872db 100644 --- a/versioned_docs/version-6.x/ecosystem-vue.md +++ b/versioned_docs/version-6.x/ecosystem-vue.md @@ -83,7 +83,15 @@ const vueLifecycles = singleSpaVue({ Vue, appOptions: { render(h) { - return h(App); + return h(App, { + props: { + // single-spa props are available on the "this" object. Forward them to your component as needed. + // https://single-spa.js.org/docs/building-applications#lifecycle-props + name: this.name, + mountParcel: this.mountParcel, + singleSpa: this.singleSpa, + } + }); }, router, }, @@ -132,35 +140,40 @@ export const unmount = vueLifecycles.unmount; ## Custom props -[Single-spa custom props](/docs/building-applications/#custom-props) can be passed to your root component like so: +[Single-spa custom props](/docs/building-applications/#custom-props) can be passed to your root component. In your application's entry file, add the props to your root component: + +### Vue 2 ```js -// main.js const vueLifecycles = singleSpaVue({ Vue, appOptions: { render(h) { return h(App, { - mountParcel: this.mountParcel, - otherProp: this.otherProp, + props: { + otherProp: this.otherProp, + }, }); }, - router, }, }); ``` +### Vue 3 -```vue -// App.vue - - +```js +const vueLifecycles = singleSpaVue({ + Vue, + appOptions: { + render(h) { + return h(App, { + // Notice that this is not within a props object! + otherProp: this.otherProp, + }); + }, + router, + }, +}); ``` ## Shared dependencies @@ -232,29 +245,6 @@ const vueLifecycles = singleSpaVue({ }); ``` -## Custom Props - -[single-spa custom props](/docs/building-applications#custom-props) are available in the `render()` function in your main file. They can be passed as custom props to your App component. - -```js -const vueLifecycles = singleSpaVue({ - Vue, - appOptions: { - render(h) { - return h(App, { - props: { - // single-spa props are available on the "this" object. Forward them to your component as needed. - // https://single-spa.js.org/docs/building-applications#lifecycle-props - name: this.name, - mountParcel: this.mountParcel, - singleSpa: this.singleSpa, - }, - }); - }, - }, -}); -``` - ## Parcels ### Creating a parcel