收藏
回答

使用watch和immediate: true时报错?

let unTokenWatch = this.$watch('token', () => {
	console.log("===$watch ==", that.token);
	that.getNewsListByCode(that.newTypes[that.current]);
	unTokenWatch();
}, {
	// 	immediate: true
})


immediate: true时报错:

TypeError: unTokenWatch is not a function
    at VueComponent.unTokenWatch.$watch.immediate (VM8961 home.js:360)
    at VueComponent.Vue.$watch (VM8927 vendor.js:7844)
    at VueComponent.getMoreNewsList (VM8961 home.js:358)
    at VueComponent.onShow (VM8961 home.js:267)
    at invokeWithErrorHandling (VM8927 vendor.js:5147)
    at VueComponent.Vue.__call_hook (VM8927 vendor.js:8766)
    at ve.mpOptions.<computed> [as onShow] (VM8927 vendor.js:760)
    at ve.<anonymous> (VM8920 WAService.js:1)
    at ve.p.__callPageLifeTime__ (VM8920 WAService.js:1)
    at Tt (VM8920 WAService.js:1)


第一次报错,第二次进入正常??
回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2020-06-17

    2020-06-17
    有用 1
    回复
登录 后发表内容
问题标签