网站目录当然要为中文和英文各建一个独立的目录,里面放置各自的页面了。
如果使用数据库的话,则思路是一样的。
var Chinese = new RegExp('[\u4E00-\u9FA5]+') //中文
var Letter = new RegExp('[A-Za-z]+') //字母
if (Chinese.test(this.systemInput)) {
//中文搜索
this.showOpList = this.List.filter(array => {
if (array.title != undefined) {
return array.title.indexOf(this.systemInput) >= 0
}
return false
})
}
if (Letter.test(this.systemInput)) {
//字母搜索
this.showOpList = this.List.filter(array => {
let flag = false
if (array.letter != undefined) {
flag = array.letter.indexOf(this.systemInput) >= 0
}
if (array.spelling != undefined && !flag) {
flag = array.spelling.indexOf(this.systemInput) >= 0
}
return flag
})
}
如果是网站的话通常做两套中英各一套然后相互跳转
如果你一定要用js切换
那只能做一套中英对照表先
然后切换的时候将表里的内容互换就行了