vue 控制台报错

TypeError: data.indexOf is not a function
    at TableStore.module.exports.TableStore.updateCurrentRow (element-ui.common.js?ccbf:11270)
    at TableStore.setData (element-ui.common.js?ccbf:10762)
    at TableStore.module.exports.TableStore.commit (element-ui.common.js?ccbf:11286)
    at VueComponent.handler (element-ui.common.js?ccbf:10481)
    at VueComponent.Vue.$watch (vue.esm.js?efeb:3613)
    at createWatcher (vue.esm.js?efeb:3571)
    at initWatch (vue.esm.js?efeb:3553)
    at initState (vue.esm.js?efeb:3317)
    at VueComponent.Vue._init (vue.esm.js?efeb:4628)
    at new VueComponent (vue.esm.js?efeb:4798)

我代码中没有用到indexOf这个方法,但是却报错了,然后页面显示不出来了,有大神知道这是什么错误吗,多谢啦

阅读 13.6k
3 个回答

报错很明显了,TypeError: data.indexOf is not a function表示这不是一个方法

根据查询MDN:Array的indexOfString的indexOf 两种方法,表示indexOf只有在Array原型和String原型上才能使用

所以请你检查一下你的data是不是属于Array或者是String

String/Array才有indexOf方法,提示类型错误(TypeError),自然就是说data既不是字符串,也不是数组。你断点看下data是什么。

报错data.indexOf is not a function
明义理解就是楼上所说,但是并不一定是变量 data 看看报错信息在哪个js 然后debug 看看什么变量走进了这个检测

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题