vue在微信里面的兼容问题_vuejs在安卓系统下微信X5内核这个兼容性问题如何破?...
小弟第一次使用vue.js做項目開發就遇到了一個坑,本想把區域選擇獨立為一個子組件來使用,但是組件模式開發的select區域下拉列表在安卓系統的騰訊系的X5內核竟然報錯了,導致彈出的select選擇框無法選擇。
目前測試此問題存在于安卓系統下的騰訊系瀏覽器,UC系瀏覽器或webview,安卓下其他瀏覽器無問題。
有問題
無問題
主要代碼:
省
{{ currSheng }}
{{ sheng }}
市
{{ currShi }}
{{ shi }}
區
{{ currQu }}
{{ qu }}
import RegionData from './js/region-data.js'
export default{
name: 'region-picker',
data () {
return {
regionType: 1,
isQU: true,
shengObj: {},
shiObj: {},
quObj: {},
selectArray: {
sheng: [],
shi: [],
qu: []
},
currSheng: undefined,
currShi: undefined,
currQu: undefined
}
},
created: function () {
this.getSelectArray(0)
},
watch: {
currSheng: function (val, oldVal) {
this.selectArray.shi = []
this.selectArray.qu = []
let level = 1
this.shengObj = RegionData.find(
function (x) {
return x.name === val
}
)
this.regionType = this.shengObj.type
this.getSelectArray(level) // 渲染城市列表
this.currShi = undefined
},
currShi: function (val, oldVal) {
if (this.currShi !== undefined) {
this.shiObj = undefined
let level = 2
if (this.regionType === 0) { // 如果城市只有兩級,停止渲染區列表,返回數據
this.isQU = false
this.currQu = undefined
this.returnRegion(level)
} else {
this.isQU = true
this.shiObj = this.shengObj.sub.find(
function (x) {
return x.name === val
}
)
this.selectArray.qu = []
this.getSelectArray(level) // 渲染區域列表
this.currQu = undefined
}
}
},
currQu: function (val, oldVal) {
if (this.currQu !== undefined) {
this.returnRegion()
}
}
},
methods: {
getSelectArray: function (level) {
if (level === 0) { // 渲染省份列表
for (var i = 0; i < RegionData.length; i++) {
this.selectArray.sheng.push(RegionData[i].name)
}
} else if (level === 1) { // 渲染城市列表
for (i = 0; i < this.shengObj.sub.length; i++) {
this.selectArray.shi.push(this.shengObj.sub[i].name)
}
} else if (level === 2 && this.regionType === 1) {
for (i = 0; i < this.shiObj.sub.length; i++) {
this.selectArray.qu.push(this.shiObj.sub[i].name)
}
}
},
returnRegion (level) {
let regionData
if (level === 2) {
regionData = this.currSheng + this.currShi
} else {
regionData = this.currSheng + this.currShi + this.currQu
}
this.$emit('getRegion', regionData)
}
}
}
總結
以上是生活随笔為你收集整理的vue在微信里面的兼容问题_vuejs在安卓系统下微信X5内核这个兼容性问题如何破?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python def method_给p
- 下一篇: html5倒计时秒杀怎么做,vue 设