首页
导航
博客
电子书
算法
众创
代码
随贴
关于我们
您好,欢迎来到码863代码分享网! 请
[登录]
/
[注册]
搜 索
标题:
*
140
字
TAG标签:
(用空格隔开)
30
字
恢复历史版本:
请选择分类
html
python
javascript
php
sql
c
c++
c#
java
plain
所有人可见
仅自己可见
编辑器:UEditor
编辑器:TinyMCE
编辑器:Editor.md
HTML转MD
HTML转MD2
<p><br/>打包国际化处理,主要是引导用户的提示语,如申请权限等 <a href="https://ask.dcloud.net.cn/article/35860">https://ask.dcloud.net.cn/article/35860</a></p><p><br/></p><p><br/>uni-app全方位多语言 https://ask.dcloud.net.cn/article/35872</p><p><br/></p><p><br/></p><p><br/></p><p>我的项目是直接在HBuilderX 创建的,所以需要使用npm init -y 初始化package.json文件</p><p>npm init -y</p><p>安装vue-i18n 命令如下</p><p>npm i vue-i18n</p><p>\lang.js</p><pre class="brush:js;toolbar:false">export default { 'en-US': { index: { invite: 'Invite', game: 'Game' } }, 'zh-CN': { index: { invite: '邀请', game: '游戏' } } }</pre><p>\main.js</p><pre class="brush:js;toolbar:false">import Vue from 'vue' import App from './App' import messages from './lang' import VueI18n from 'vue-i18n' Vue.use(VueI18n) const i18n = new VueI18n({ locale: 'en-US', messages }) Vue.prototype._i18n = i18n Vue.prototype.$i18nMsg = function(){ return i18n.messages[i18n.locale] } const app = new Vue({ i18n, ...App }) app.$mount()</pre><p><br/>\pages\index\index.vue</p><pre class="brush:js;toolbar:false"><template> <view> <view>{{ i18n.index.invite }}</view> </view> </template> <script> export default { data() { return { title: 'Hello' } }, computed: { i18n() { return this.$i18nMsg() } }, onLoad() { setTimeout(() => { this.$i18n.locale = 'zh-CN' },2000) }, methods: { } } </script> <style rel="stylesheet/stylus"> .content-title color #500778 </style></pre><p><br/></p>
CopyRight 2002~2023 精通2100网 联系邮箱:qqtxt@163.com
版权所有:精通2100网
湘ICP备2023018646号-1
MYSQl共执行 4 个查询,用时 0.0021884441375732 秒,PHP脚本用时 0.004689 秒,占用内存 0.523 MB,Gzip 已启用