目录
官网详解:https://uniapp.dcloud.net.cn/tutorial/i18n.html
我创建项目的时候选择的模板是uni-ui项目,所以不需要npm vue-i18n
import messages from './locale/index'//(1)
let i18nConfig = { //(2)
locale: uni.getLocale(),//获取系统语言
messages
}
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import store from './store'
import api from '@/http/vmeitime-http/index.js'
import share from '@/utils/share.js'
Vue.mixin(share)
import VueI18n from 'vue-i18n'//(3)
Vue.use(VueI18n)//(4)
const i18n = new VueI18n(i18nConfig)//(5)
Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.api = api
App.mpType = 'app'
const app = new Vue({
...App,
store,
share,
i18n,//(6)
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
import App from './App.vue'
//(7)
import {
createI18n
} from 'vue-i18n'
const i18n = createI18n(i18nConfig)//(8)
export function createApp() {
const app = createSSRApp(App)
app.use(i18n)//(9)
return {
app
}
}
// #endif
locale文件夹是与pages同级
locale/en.json(英文模板)
{
"locale.auto": "System",
"locale.en": "English",
"locale.zh-hans": "简体中文",
"index.scene": "Scene",
"index.company": "Company Profile",
"index.package": "Package",
"index.details": "Details",
"word.whole": "whole",
"word.download": "Download Records",
"word.preservation": "Transfer to my mobile phone",
"word.forward": "Forward to friends",
"me.WeChat": "WeChat name",
"me.message": "Message feedback",
"me.myDownloads": "My Downloads",
"me.contact": "contact us",
"me.logout": "Log out"
}
locale/ zh-Hans(简体中文)
{
"locale.auto": "系统",
"locale.en": "English",
"locale.zh-hans": "简体中文",
"index.scene": "场景",
"index.company": "公司介绍",
"index.package": "产品包",
"index.details": "详情",
"word.whole": "全部",
"word.download": "下载记录",
"word.preservation": "转存到我的手机",
"word.forward": "转发给朋友",
"me.WeChat": "微信名",
"me.message": "留言反馈",
"me.myDownloads": "我的下载",
"me.contact": "联系我们",
"me.logout": "退出登录"
}
locale/index.js
import en from './en.json'
import zhHans from './zh-Hans.json'
export default {
en,
'zh-Hans': zhHans,
}
在首页pages/index/index.vue
在首页必须这样写,其他页面就只要写(5)即可
<template>
<view class="container">
//(5)
<view>{{$t('index.scene')}}</view>
</view>
</template>
<script>
export default {
computed: { //(1)
locales() {
return [{
text: this.$t('locale.auto'),
code: 'auto'
},{
text: this.$t('locale.en'),
code: 'en'
}, {
text: this.$t('locale.zh-hans'),
code: 'zh-Hans'
}
]
}
},
data() {
return {
applicationLocale: '', //语言//(2)
systemLocale:''
};
},
onLoad() {
//(3)
let systemInfo = uni.getSystemInfoSync();
this.systemLocale = systemInfo.language;
this.applicationLocale = uni.getLocale();
this.isAndroid = systemInfo.platform.toLowerCase() === 'android';
uni.onLocaleChange((e) => {
this.applicationLocale = e.locale;
})
//h5页面设置成英文
/*#ifdef H5*/
this.applicationLocale = 'en';
this.$i18n.locale = 'en'
/*#endif*/
},
methods: {
//(4)
onLocaleChange(e) {
if (this.isAndroid) {
uni.showModal({
content: this.$t('index.language-change-confirm'),
success: (res) => {
if (res.confirm) {
uni.setLocale(e.code);
}
}
})
} else {
uni.setLocale(e.code);
this.$i18n.locale = e.code;
}
},
}
}
</script>
注意:
(1)、在template中使用的格式:{{$t('index.scene')}}
(2)、在data里数值的替换方法:this.$t('index.scene')
<template>
<view class="me-container">
<uni-list v-for="(item,index) in list" :key='index'>
<uni-list-item :title="item.title" clickable="true" thumb-size="medium" showArrow
:rightText="item.rightText?item.rightText:''" @click="pages(item,index)">
<template v-slot:header>
<view class="slot-box">
<image class="slot-image" :src="item.thumb" mode="widthFix"></image>
</view>
</template>
</uni-list-item>
</uni-list>
</view>
</template>
<script>
export default {
data() {
return {
list: [],
};
},
onLoad() {
//template正常写,不变,数组使用push的方法,对象同理
//必须使用push的方式,若使用list:[me.message,me.myDownloads]无效
this.list.push( {
title: this.$t('me.message'),
thumb: '../../static/lyfkicon.png'
},{
title: this.$t('me.myDownloads'),
thumb: '../../static/wdxzicon.png'
}, {
title: this.$t('me.contact'),
rightText: '400-123-1234',
thumb: '../../static/lxwmicon.png'
}, {
title: this.$t('me.logout'),
thumb: '../../static/tcdlicon.png'
})
},
}
</script>
先获取系统语言,然后把获取的语言存储起来,方便之后判断。
后端传给我的是以下格式:
{
Name:'名字'//中文
Name_EN:'name'//英文
}
app.vue
onLaunch: function() {
this.$store.commit('SET_LOCALE', uni.getLocale())
},
store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
getLocale: 'zh-Hans'
},
getters: {
getLocale: state => state.getLocale,
},
mutations: {
SET_LOCALE: (state, getLocale) => {
state.getLocale = getLocale
},
}
})
export default store
页面使用
<template>
<view class="container">
//第一种
<text>{{applicationLocale==='zh-Hans'?list.Title2:list.Title2_EN}}</text>
//第二种
<text>{{list.Name}}</text>
</view>
</template>
<script>
export default {
data() {
return {
list: [], //资源包的数据
SceneData: {}, //上一页携带的参数
applicationLocale: '', //语言
};
},
onLoad(e) {
this.applicationLocale = this.$store.state.getLocale
//第二种,直接在函数中判断赋值,template中正常写
this.GetDataGramsList()
//第一种,获取到上一页参数,然后直接在template中使用三元表达式判断即可
//这里上一页参数就是后端传过来的数据
this.SceneData = JSON.parse(e.Scene)
uni.setNavigationBarTitle({
title: this.SceneData.Name,
})
},
methods: {
GetDataGramsList() {
let that = this
this.api.GetDataGramsList({
sceneid: that.SceneData.Id
}).then(res => {
this.list = res.data.Data
this.list.forEach(i => {
if (this.applicationLocale !== 'zh-Hans') {
i.Name = i.Name_EN
i.Img = i.Img_EN
i.Id = i.Id
i.Introduction = i.Introduction_EN
i.Scene = i.Scene_EN
}
})
})
},
}
}
</script>
pages.json固定数据
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/homr/index",
"style": {
"navigationBarTitleText": "%index.title%"
}
}, {
"path": "pages/word/index",
"style": {
"navigationBarTitleText": "%index.word%",
"enablePullDownRefresh": false
}
}
],
}
动态参数--由后端返回的数据作为标题
pages.json
{
"pages": [
{
"path": "pages/word/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
}
页面
onLoad(e) {
let that = this
this.content = JSON.parse(e.item)
if (this.$store.state.getLocale === 'zh-Hans') {
uni.setNavigationBarTitle({
title: that.content.Name,
})
} else {
uni.setNavigationBarTitle({
title: that.content.Name_EN,
})
}
},
pages.json固定数据
{
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
"borderStyle": "black",
"backgroundColor": "#F8F8F8",
"list": [{
"pagePath": "pages/home/index",
"text": "%index.home%"
},
{
"pagePath": "pages/word/index",
"text": "%index.word%"
}
]
},
}
若是不生效那就只能在tab页面中使用uni.setTabBarItem
我是把所有的都写了首页的onShow里面
onShow() {
uni.setTabBarItem({
index: 0,
pagePath: "pages/index/index",
iconPath: "static/syicon1.png",
selectedIconPath: "static/syicon2.png",
text: this.$t('pages.home')
})
uni.setTabBarItem({
index: 1,
pagePath: "pages/word/index",
iconPath: "static/chanpin.png",
selectedIconPath: "static/wjicon.png",
text: this.$t('pages.word')
})
uni.setTabBarItem({
index: 2,
pagePath: "pages/me/index",
iconPath: "static/wdicon1.png",
selectedIconPath: "static/wdicon2.png",
text: this.$t('pages.me')
})
},
uni.showModal({
title: "提示",
content: "请输入正确的信息!",
success: res => {
if (res.confirm) {
this.popupShow = true
} else {}
}
});
uni.showModal({
title: this.$t('uniapp.title'),
content: this.$t('uniapp.content'),
success: res => {
if (res.confirm) {
this.popupShow = true
} else {}
}
});
在VMware16.2.4安装Ubuntu一、安装VMware1.打开VMwareWorkstationPro官网,点击即可进入。2.进入后向下滑动找到Workstation16ProforWindows,点击立即下载。3.下载完成,文件大小615MB,如下图:4.鼠标右击,以管理员身份运行。5.点击下一步6.勾选条款,点击下一步7.先勾选,再点击下一步8.去掉勾选,点击下一步9.点击下一步10.点击安装11.点击许可证12.在百度上搜索VM16许可证,复制填入,然后点击输入即可,亲测有效。13.点击完成14.重启系统,点击是15.双击VMwareWorkstationPro图标,进入虚拟机主
前言一般来说,前端根据后台返回code码展示对应内容只需要在前台判断code值展示对应的内容即可,但要是匹配的code码比较多或者多个页面用到时,为了便于后期维护,后台就会使用字典表让前端匹配,下面我将在微信小程序中通过wxs的方法实现这个操作。为什么要使用wxs?{{method(a,b)}}可以看到,上述代码是一个调用方法传值的操作,在vue中很常见,多用于数据之间的转换,但由于微信小程序诸多限制的原因,你并不能优雅的这样操作,可能有人会说,为什么不用if判断实现呢?但是if判断的局限性在于如果存在数据量过大时,大量重复性操作和if判断会让你的代码显得异常冗余。wxswxs相当于是一个独立
项目介绍随着我国经济迅速发展,人们对手机的需求越来越大,各种手机软件也都在被广泛应用,但是对于手机进行数据信息管理,对于手机的各种软件也是备受用户的喜爱小学生兴趣延时班预约小程序的设计与开发被用户普遍使用,为方便用户能够可以随时进行小学生兴趣延时班预约小程序的设计与开发的数据信息管理,特开发了小程序的设计与开发的管理系统。小学生兴趣延时班预约小程序的设计与开发的开发利用现有的成熟技术参考,以源代码为模板,分析功能调整与小学生兴趣延时班预约小程序的设计与开发的实际需求相结合,讨论了小学生兴趣延时班预约小程序的设计与开发的使用。开发环境开发说明:前端使用微信微信小程序开发工具:后端使用ssm:VU
@作者:SYFStrive @博客首页:HomePage📜:微信小程序📌:个人社区(欢迎大佬们加入)👉:社区链接🔗📌:觉得文章不错可以点点关注👉:专栏连接🔗💃:感谢支持,学累了可以先看小段由小胖给大家带来的街舞👉微信小程序(🔥)目录自定义组件-behaviors 1、什么是behaviors 2、behaviors的工作方式 3、创建behavior 4、导入并使用behavior 5、behavior中所有可用的节点 6、同名字段的覆盖和组合规则总结最后自定义组件-behaviors 1、什么是behaviorsbehaviors是小程序中,用于实现
作为新的阿里云用户,您可以50免费试用多种优惠,价值高达1,700美元(或8,500美元)。这将让您了解和体验阿里云平台上提供的一系列产品和服务。如果您以个人身份注册免费试用,您将获得价值1,700美元的优惠。但是,如果您是注册公司,您可以选择企业免费试用,提交基本信息通过企业实名注册验证,即可开始价值$8,500的免费试用!本教程介绍了如何设置您的帐户并使用您的免费试用版。关于免费试用在我们开始此试用之前,您还必须遵守以下条款和条件才能访问您的免费试用:只有在一年内创建的账户才有资格获得阿里云免费试用。通过此免费试用优惠,用户可以免费试用免费试用活动页面上列出的每种产品一次。如果您有多个帐
1.问题描述使用Python的turtle(海龟绘图)模块提供的函数绘制直线。2.问题分析一幅复杂的图形通常都可以由点、直线、三角形、矩形、平行四边形、圆、椭圆和圆弧等基本图形组成。其中的三角形、矩形、平行四边形又可以由直线组成,而直线又是由两个点确定的。我们使用Python的turtle模块所提供的函数来绘制直线。在使用之前我们先介绍一下turtle模块的相关知识点。turtle模块提供面向对象和面向过程两种形式的海龟绘图基本组件。面向对象的接口类如下:1)TurtleScreen类:定义图形窗口作为绘图海龟的运动场。它的构造器需要一个tkinter.Canvas或ScrolledCanva
提供3种Ubuntu系统安装微信的方法,在Ubuntu20.04上验证都ok。1.WineHQ7.0安装微信:ubuntu20.04安装最新版微信--可以支持微信最新版,但是适配的不是特别好;比如WeChartOCR.exe报错。2.原生微信安装:linux系统下的微信安装(ubuntu20.04)--微信适配的最好,反应最快,但是微信版本只到2.1.1,版本太老,很多功能都没有。3.深度deepin-wine6安装微信:ubuntu20.04+系统deepin-wine6安装新版微信--综合比较好,当前个人使用此种方法1个月,微信版本3.4;没什么大问题,尚可。一、WineHQ7.0安装微信
对传统的餐饮商家来说,小程序很好地解决了餐厅线下线上连接的问题,在引流获客、节约人力、营销宣传、塑造会员体系、改善消费体验等方面都有很大帮助。小程序点餐可以帮助餐饮企业节省一大把人力开支。一个包含扫码点单、菜品管理、优惠券推送、外卖配送的小程序,商家花几万元就能完成开发测试并投入。商家为什么要开通“扫码点餐”1.解决服务员不够用的问题。2.不怕顾客跑单漏单。3.在微信就能管理菜品、查看营业额。4.订单小票显示顾客桌号和已点菜品。5.可在“附近的小程序”找到您的门店。如今餐饮业常用的三种经营模式:1堂食点单模式客人通过小程序堂食点单。商家可以在微信扫码点餐小程序管理后台根据自己店内情况来设置不同
技术选型1,前端小程序原生MINA框架cssJavaScriptWxml2,管理后台云开发Cms内容管理系统web网页3,数据后台小程序云开发云函数云开发数据库(基于MongoDB)云存储4,人脸识别算法基于百度智能云实现人脸识别一,用户端效果图预览老规矩我们先来看效果图,如果效果图符合你的需求,就继续往下看,如果不符合你的需求,可以跳过。1-1,登录注册页可以看到登录页有注册入口,注册页如下我们的注册,需要管理员审核,审核通过后才可以正常登录使用小程序1-2,个人中心页登录成功以后,我们会进入个人中心页我们在个人中心页可以注册人脸,因为我们做人脸识别签到,需要先注册人脸才可以进行人脸比对,进
目录H2数据库入门以及实际开发时的使用1.H2数据库的初识1.1H2数据库介绍1.2为什么要使用嵌入式数据库?1.3嵌入式数据库对比1.3.1性能对比1.4技术选型思考2.H2数据库实战2.1H2数据库下载搭建以及部署2.1.1H2数据库的下载2.1.2数据库启动2.1.2.1windows系统可以在bin目录下执行h2.bat2.1.2.2同理可以通过cmd直接使用命令进行启动:2.1.2.3启动后控制台页面:2.1.3spring整合H2数据库2.1.3.1引入依赖文件2.1.4数据库通过file模式实际保存数据的位置2.2H2数据库操作2.2.1Mysql兼容模式2.2.2Mysql模式