-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot pass vue-i18n object into web-component #216
Comments
Hey, don't know if that helps but a coworker of mine added i18next with a mixin that he then installed in Vue: i18next-mixin.ts:
then you install it to Vue using:
and in the Element you use the $t() method, but I think you can change it by changing it in this line: Vue.prototype .$t = function (namespace: string, options: TranslationOptions | undefined) { I hope this helps at least a bit, Regards Lucas |
Hi, all seems to work for me - https://codesandbox.io/s/vue-template-o1fsc?file=/src/main.js |
It's working because you are not using Typescript + Class based components. Using typescript I you have to create a new instance of Test component in the main.ts file Sadly I couldn't start a typescript sandbox to reproduce the error... import ModuleLayout from '@/components/modules/layout/ModuleLayout.vue';
import VueCustomElement from 'vue-custom-element';
Vue.use(VueCustomElement);
Vue.customElement('skyroom-layout', ModuleLayout); // line 32 And the error:
And this code has no errors but without i18n: import ModuleLayout from '@/components/modules/layout/ModuleLayout.vue';
import VueCustomElement from 'vue-custom-element';
Vue.use(VueCustomElement);
const layout = new ModuleLayout({ i18n }).$options;
Vue.customElement('skyroom-layout', layout); |
Hi, it seems to work like this. Please let me know if it will work for You - https://codesandbox.io/s/vue-template-72o5z?file=/src/main.js
|
Had problems with this and i solved it with the following code:
|
I have a component that uses vue-i18n and works as a normal vue component.
When creating web component I had
TypeError: this is undefined
error with typescript, then created the component with this approach:And this is my i18n object:
For adding i18n I tried these approaches but none works:
In both ways I have these errors:
The text was updated successfully, but these errors were encountered: