chore(examples): update event context (#8814)

This commit is contained in:
Cue 2022-11-09 09:05:52 +00:00 committed by GitHub
parent 10c2272f4f
commit f26c97f05a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,8 +6,7 @@ export const useDefaultLocale = (fallback = 'en-US') => {
const locale = ref(fallback) const locale = ref(fallback)
if (process.server) { if (process.server) {
// Learn more about the nuxtApp interface on https://v3.nuxtjs.org/docs/usage/nuxt-app#nuxtapp-interface-advanced // Learn more about the nuxtApp interface on https://v3.nuxtjs.org/docs/usage/nuxt-app#nuxtapp-interface-advanced
const nuxtApp = useNuxtApp() const reqLocale = useRequestHeaders()['accept-language']?.split(',')[0]
const reqLocale = nuxtApp.ssrContext?.req.headers['accept-language']?.split(',')[0]
if (reqLocale) { if (reqLocale) {
locale.value = reqLocale locale.value = reqLocale
} }