We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
复现:
npx degit dcloudio/uni-preset-vue#vite my-vue3-project cd .\my-vue3-project\ pnpm i pnpm add @dcloudio/uni-ui sass
按官方教程添加vue.config.js和easycom配置 然后添加leftWindow设置(修改为topWindow或rightWindow也一样)
"leftWindow": { "path": "pages/index/index.vue" // 指定 leftWindow 页面文件 }
再在index.vue中添加uni-search-bar组件: <uni-search-bar :focus="true"></uni-search-bar>
<uni-search-bar :focus="true"></uni-search-bar>
最后跑起来 pnpm run dev:h5 在浏览器中可以看到uni-search-bar组件显示为英文 经过调试,发现原因为在left/top/rightWindow优先main初始化,uni-search-bar使用initVueI18n(messages)初始化i18n @dcloudio/uni-i18n中会走到getDefaultLocale,然后在当前环境中uni和global都是未定义,直接return LOCALE_EN了 根本原因还是此时读取不到uni变量,由此可以判断除了i18n,可能还会有其他相关问题 该问题会导致共用组件在main中也会表现出一样的问题,因为初始化代码只会执行一次,比如uni-search-bar虽然在window和main中都使用了,但是由于语言代码在初始化阶段就已经调用完了,后续是复用,所以在main中也会显示为英文
pnpm run dev:h5
initVueI18n(messages)
@dcloudio/uni-i18n
getDefaultLocale
uni
global
return LOCALE_EN
The text was updated successfully, but these errors were encountered:
No branches or pull requests
复现:
按官方教程添加vue.config.js和easycom配置
然后添加leftWindow设置(修改为topWindow或rightWindow也一样)
再在index.vue中添加uni-search-bar组件:
<uni-search-bar :focus="true"></uni-search-bar>
最后跑起来
pnpm run dev:h5
在浏览器中可以看到uni-search-bar组件显示为英文
经过调试,发现原因为在left/top/rightWindow优先main初始化,uni-search-bar使用
initVueI18n(messages)
初始化i18n@dcloudio/uni-i18n
中会走到getDefaultLocale
,然后在当前环境中uni
和global
都是未定义,直接return LOCALE_EN
了根本原因还是此时读取不到
uni
变量,由此可以判断除了i18n,可能还会有其他相关问题该问题会导致共用组件在main中也会表现出一样的问题,因为初始化代码只会执行一次,比如uni-search-bar虽然在window和main中都使用了,但是由于语言代码在初始化阶段就已经调用完了,后续是复用,所以在main中也会显示为英文
The text was updated successfully, but these errors were encountered: