跳到主要内容

useNavigatorLanguage

分类
导出大小
759 B
上次更改
3 个月前

响应式的 navigator.language

演示

支持: false

导航器语言
你的浏览器不支持 Navigator.language API。

用法

ts
import { 
useNavigatorLanguage
} from '@vueuse/core'
const {
language
} =
useNavigatorLanguage
()
watch
(
language
, () => {
// Listen to the value changing })

类型声明

显示类型声明
ts
export interface NavigatorLanguageState {
  
isSupported
:
ComputedRef
<boolean>
/** * * ISO 639-1 standard Language Code * * @info The detected user agent language preference as a language tag * (which is sometimes referred to as a "locale identifier"). * This consists of a 2-3 letter base language tag that indicates a * language, optionally followed by additional subtags separated by * '-'. The most common extra information is the country or region * variant (like 'en-US' or 'fr-CA'). * * * @see https://www.iso.org/iso-639-language-codes.html * @see https://www.loc.gov/standards/iso639-2/php/code_list.php * */
language
:
ShallowRef
<string | undefined>
} /** * * Reactive useNavigatorLanguage * * Detects the currently selected user language and returns a reactive language * @see https://vueuse.org.cn/useNavigatorLanguage * * @__NO_SIDE_EFFECTS__ */ export declare function
useNavigatorLanguage
(
options
?:
ConfigurableWindow
,
):
Readonly
<NavigatorLanguageState>
export type
UseNavigatorLanguageReturn
=
ReturnType
<typeof
useNavigatorLanguage
>

来源

源代码演示文档

贡献者

Anthony Fu
SerKo
IlyaL
Anthony Fu
Fernando Fernández
Alex Liu
vaakian X
Jelf
WuLianN
Michael J. Roberts

更新日志

v13.6.0
d32f8 - refactor: 为所有纯函数添加 @__NO_SIDE_EFFECTS__ 注释 (#4907)
v12.4.0
dd316 - feat: 尽可能在所有地方使用被动事件处理程序 (#4477)
0a9ed - feat!: 放弃对 Vue 2 的支持,优化打包并清理 (#4349)

根据 MIT 许可证发布。