Replies: 1 comment 1 reply
-
If you want to use Vue 3 to create web components, you will need to do the following
Note that VueI18n for web components will be supported in the future since Vue 3.2 was recently released. We'll plan to support web components in the [email protected] official release. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm creating a Vue web component using vue-cli 4.5.13 and the --target wc option. I also need the component to use the vue-i18n-next plugin (last version for vue 3 projects), which requires some options to be passed to the main Vue instance, but now there is no main instance since the entrypoint is the vue component itself, so i18n has to be instantiated within the component.
Old vue2 i18n option works, but instantiating the i18n object in the component options is not valid for vue3 (this.$i18n stays undefined). So this is not working:
export default {
name: "custom-compo",
i18n: i18n,
components: { ChildComponent }
data, methods...
};
The solution should work both if exporting the web component (and using it on a standard page) and also if
npm run serve
ing a standard app with this component inside (but again instantiating i18n in the compo, not in main.js)I am not asking how to setup vue-i18n within a normal vue project, but how to initialise i18n within a component that's gonna be built or exported as a custom-element or web-component, using the vue-cli, with vue 3 (
npm run build --target wc
)I am not using composition api with setup(), but old options api. Just upgraded to vue3 package and updated deprecated syntax as per docs.
Beta Was this translation helpful? Give feedback.
All reactions