uni-app 中英文切换

	 要下载一个语言包
	 要是不看代码的话,这边有我一个案例,下载直接用
	 链接:https://download.csdn.net/download/weixin_44186787/12412209
	  //  顶部
		uni.setNavigationBarTitle({
            title: this.$t('index.navTitleFour')
        });

//首页
    computed: {
        i18n() {
            return this.$t('index');
        }
    },
// 切换语言按钮
change() {
            const system_info = uni.getStorageSync('system_info');
            system_info.language === 'en' ? (system_info.language = this._i18n.locale = 'zh_CN') : (system_info.language = this._i18n.locale = 'en');
            uni.setStorageSync('system_info', system_info);
            uni.reLaunch({
                url: 'index'
            });
            if(system_info.language === 'en'){
                uni.setNavigationBarTitle({
                    title: this.$t('index.pingtai')
                })
                uni.setTabBarItem({
                    index:0,
                    text: this.i18n.navTitle
                });
                uni.setTabBarItem({
                    index:1,
                    text: this.i18n.navTitleTwo
                });
                uni.setTabBarItem({
                    index:2,
                    text: this.i18n.navTitleThree
                });
                uni.setTabBarItem({
                    index:3,
                    text: this.i18n.navTitleFour
                });
            }else {
                uni.setNavigationBarTitle({
                    title: this.$t('index.pingtai')
                })
                uni.setTabBarItem({
                    index:0,
                    text: this.i18n.navTitle
                });
                uni.setTabBarItem({
                    index:1,
                    text: this.i18n.navTitleTwo
                });
                uni.setTabBarItem({
                    index:2,
                    text: this.i18n.navTitleThree
                });
                uni.setTabBarItem({
                    index:3,
                    text: this.i18n.navTitleFour
                });
            }
            
        },

    底部导航栏(某个导航的页面)
        uni.setTabBarItem({
            index: 0,
            text: this.i18n.navTitle
        });
        uni.setTabBarItem({
            index: 2,
            text: this.i18n.navTitleTwo
        });
        uni.setTabBarItem({
            index: 1,
            text: this.i18n.navTitleThree
        });
        uni.setTabBarItem({
            index: 3,
            text: this.i18n.navTitleFour
        });
上一篇:前端国际化辅助工具——自动替换中文并翻译


下一篇:在Cygwin中出现JAVA_HOME出现问题找不到出现问题