猿问

Error in nextTick: "TypeError: Cannot read property '0' of undefined"


我在学《饿了么webapp》开发中遇到:

created () {

    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']

    this.$http.get('/api/goods').then(response => {

      this.goods = response.body.data

      console.log(this.goods)

      this.$nextTick(() => {

        this._initScroll()

      })

    }, response => {

    // error callback

    })

  },

  methods: {

    _initScroll () {

      this.meunScroll = new BScroll(this.$refs.menuWrapper, {})

      this.foodsScroll = new BScroll(this.$refs.foodsWrapper, {})

    }

  }

我用的vue2.0,跟视频里面不一样。

console报错:

Error in nextTick: "TypeError: Cannot read property '0' of undefined"

大神帮忙看看nextTick这个函数怎么会报错,谢谢啦


littlefire
浏览 8258回答 1
1回答

pardon110

请保持版本一致。
随时随地看视频慕课网APP

相关分类

Vue.js
我要回答