Vux: Datetime组件以插件形式调用报错 提示“Cannot read property 'classList' of undefined”

Created on 4 Jan 2018  ·  6Comments  ·  Source: airyland/vux

错误提示
scroller.js?fa07:226 Uncaught TypeError: Cannot read property 'classList' of undefined

代码
main.js

import { ToastPlugin, dateFormat, LoadingPlugin, DatetimePlugin } from 'vux'
Vue.use(ToastPlugin)
Vue.use(LoadingPlugin)
Vue.use(DatetimePlugin)

index.vue

<li @click="chooseStartTime">
  <div>
    <p>开始时间1:</p>
    <p>{{time1}}</p>
    </div>
</li>
chooseStartTime () {
  let that = this
  that.$vux.datetime.show({
    cancelText: '取消',
    confirmText: '确定',
    format: 'YYYY-MM-DD HH',
    value: '2017-05-20 18',
    onConfirm (val) {
       console.log('plugin confirm', val)
    },
   onShow () {
     console.log('plugin show')
   },
   onHide () {
     console.log('plugin hide')
   }
  })
}
componendatetime

Most helpful comment

@airyland 尝试过不生效, 不过刚刚按照以下方法解决了,感谢.

更新vux到最新的版本(2.7.7)
找到src/plugins/datetime/index.js
加入require('../../components/datetime/style.less')
运行 问题解决了

All 6 comments

我也是一样的问题 请问你解决了吗
Uncaught TypeError: Cannot read property 'classList' of undefined
at Scroller.__selectItem (scroller.js?bf61:226)
at Scroller.__scrollingComplete (scroller.js?bf61:240)
at Scroller.scrollTo (scroller.js?bf61:208)
at Scroller.selectByIndex (scroller.js?bf61:170)
at Scroller.select (scroller.js?bf61:181)
at new Scroller (scroller.js?bf61:94)
at renderScroller (datetimepicker.js?2116:82)
at Array.eval (datetimepicker.js?2116:241)
at each (util.js?4266:6)
at DatetimePicker.show (datetimepicker.js?2116:226)

先试试直接引入组件 import { Datetime } from 'vux' 但是不需要使用,看能不能解决。

@airyland 尝试过不生效, 不过刚刚按照以下方法解决了,感谢.

更新vux到最新的版本(2.7.7)
找到src/plugins/datetime/index.js
加入require('../../components/datetime/style.less')
运行 问题解决了

@airyland 我试了你的方法可以,但是需要在页面是页面上使用一次组件,我的代码如下

import {Datetime} from 'vux'
components: {Datetime},

@315024900 老铁 我只能双击 6666了 太他妈的 机智了~~

在下个小版本 v2.8.1 解决样式注入问题。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mymmoonoa picture mymmoonoa  ·  4Comments

GloriaCHL picture GloriaCHL  ·  4Comments

RenShine picture RenShine  ·  4Comments

hjmmc picture hjmmc  ·  3Comments

hao-li picture hao-li  ·  3Comments