we-vue
we-vue copied to clipboard
datetime-picker在部分浏览器不能定位到设置的日期
datetime-picker在部分浏览器不能定位到设置的日期,调试后发现脚本有两处报错如下:
1、~\we-vue\src\components\picker\index.vue 120行
报错:children.find 找不到function
getColumn (columnIndex) {
let children = this.children
return children.find((child, index) => {
return (child.$options.name === 'wv-picker-column' && !child.divider && index === columnIndex)
})
}
改为下面的代码不报错:
getColumn (columnIndex) {
let children = this.children
let columns = children.filter((child, index) => {
return (child.$options.name === 'wv-picker-column' && !child.divider && index === columnIndex)
})
return columns.length > 0 ? columns[0] : null;
}
2、~\we-vue\src\components\picker\picker-column.vue 225行 报错:options.findIndex 找不到function
setValue (value) {
const { options } = this
const valueIndex = options.findIndex(option => {
return this.getOptionText(option) === value
})
if (valueIndex > -1) {
this.setIndex(valueIndex)
}
}
改为下面的代码不报错:
setValue (value) {
const { options } = this
let valueIndex = -1;
options.map((option,index)=>{
if(this.getOptionText(option) === value){
valueIndex = index;
}
})
if (valueIndex > -1) {
this.setIndex(valueIndex)
}
}
解决完两处报错后,可以正常定位到设置的日期。
问题总结:find 和 findIndex没有编译成浏览器都可识别的函数。