string
| Location
)string
,默认: 当前 locale)string
返回传入 route
的本地化路径。如果未指定 locale
,则使用当前 locale。
另见 基本用法 - nuxt-link。
string
)string
返回指定 locale
的当前路由路径。
另见 基本用法 - nuxt-link。
查看 Location 的类型定义。
Route
,默认: 当前路由)string
返回当前(如果未提供参数)或传入 route
的基本名称。基本名称是路由的名称,去掉了 locale 后缀和 @nuxtjs/i18n
添加的其他元数据。
RawLocation
)string
,默认: 当前 locale)Route
| undefined
返回传入 route
参数的本地化路由。如果未指定 locale
,则使用当前 locale。
另见 基本用法 - nuxt-link。
RawLocation
)string
,默认: 当前 locale)Location
| undefined
返回传入 route
参数的本地化位置。如果未指定 locale
,则使用当前 locale。
另见 基本用法 - nuxt-link。
NuxtI18nHeadOptions
)MetaInfo
options
对象接受以下可选属性:
addDirAttribute
(类型: boolean
) - 向 HTML 元素添加 dir
属性。默认: false
addSeoAttributes
(类型: boolean | SeoAttributesOptions
) - 添加各种 SEO 属性。默认: false
另见 SEO。
string | undefined
返回存储的 locale cookie 的 locale 代码。
string
)undefined
使用指定的 locale 代码更新存储的 locale cookie。如果想要切换 locale,建议使用 setLocale
。
string
)Promise<undefined>
将应用的 locale 切换到指定的 locale 代码。如果启用了 useCookie
选项,locale cookie 将更新为新值。如果启用了前缀(strategy
不等于 no_prefix
),将导航到新 locale 的路由。
string | undefined
返回经过过滤的浏览器 locale 代码,以符合选项中定义的 locale。
Promise<undefined>
切换到在导航时本会设置的待处理 locale,但由于选项 skipSettingLocaleOnNavigate
被阻止。有关更多信息,请参见 等待页面转换。
Promise<undefined>
返回一个 promise,该 promise 会在待处理 locale 设置完成后被解析。
Directions
默认方向,如选项中所指定。
string
默认 locale,如选项中所指定。
Array<string>
已注册 locales 的 locale 代码列表。
Array<string | LocaleObject>
如选项中所定义的 locales 列表。
LocaleObject
当前 locale 属性的对象。
boolean
differentDomains
选项是否启用。
Function
见 回调函数
Function
见 回调函数
以下 API 同时在 context
和 context.app
中暴露。
VueI18n
另见 Nuxt 上下文。
可以从 asyncData
和任何可用 context
的地方访问。
示例用法:
export default Vue.extend({
asyncData({ i18n }) {
const locale = i18n.locale
return {
locale
}
}
})
有关这些的更多信息,请参见 Vue 的扩展 部分。
VueI18n
可以在 store 的 actions 和 mutations 中作为 this.$i18n
访问。
示例用法:
export const actions = {
nuxtServerInit({ commit }) {
commit('LOCALE', this.$i18n.locale)
}
}
有关这些的更多信息,请参见 Vue 的扩展 部分。