Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime-picker在部分浏览器不能定位到设置的日期 #71

Open
bfu99 opened this issue Aug 27, 2018 · 0 comments
Open

datetime-picker在部分浏览器不能定位到设置的日期 #71

bfu99 opened this issue Aug 27, 2018 · 0 comments
Labels

Comments

@bfu99
Copy link

bfu99 commented Aug 27, 2018

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没有编译成浏览器都可识别的函数。

@tianyong90 tianyong90 added the bug label Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants