question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot use Vue i18n in slot templates

See original GitHub issue

Reported by @AbrahamBrookes in #14:

It seems that using the new slot feature breaks reference to my root vue app? I have a component that sits inside the eventContent slot, and I can no longer access my root vue instance (in particular, my vuex store) from that component:

		<full-calendar 
			:options="calOptions"
		>
			<template v-slot:eventContent="event" >
				<planner-period
					:event="event"
				></planner-period>
			</template>

		</full-calendar>

Inside the planner-period component when I try to access my store data using this.$store.state I get this.$store is undefined. Is the calendar creating its own entirely new vue app?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
arshawcommented, Nov 12, 2020

I’ve merged the PR and released everything in v5.4.0!

1reaction
rangermeiercommented, Sep 3, 2020

I’m wondering, as a workaround, could you somehow initialize the i18n plugin globally, using Vue.use(VueI8n) (like here)?

@arshaw I don’t think this would suffice. You still have to pass in the same i18n instance as option when initializing the Vue instance for the event content, as shown in https://kazupon.github.io/vue-i18n/started.html#javascript

Building on the attributes proposal from @kgilden: Maybe it’s possible to extract all non-default properties from this.$root.$options which would boil down to i18n, store, router, or whatever option is injected to the root Vue instance. That way the user wouldn’t have to replicate her intial Vue setup and still could make use of her Vuex store, i18n, or router state inside the scoped slot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue i18n-$t undefined outside template
Hi, Try using this.$t . – Yash Maheshwari · Where are you doing this ? Inside of data() ? – kissu · @kissu...
Read more >
I18n not working inside named slot - Get Help
I'm using theme vuexy which is made with VueSax. Inside table I want to use expand. (here is demo, click on table row...
Read more >
Breaking Changes
Vue I18n is no longer a class but a set of functions. Instead of writing new VueI18n() , you now have to call...
Read more >
The Ultimate Vue Localization Guide
In this hands-on guide, we'll use Vue I18n to internationalize a little demo app, covering everything you need to get started with Vue ......
Read more >
API references | Vue I18n
Whether to allow the use locale messages of HTML formatting. If you set warn or error , will check the locale messages on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found