现象:
type属性:选值为 index、selection、expand、html
基于iview admin二次开发,tables列描述数据对象type属性使用注意事项
当添加type属性时出现如下错误:
vue.runtime.esm.js?2b0e:587 [Vue warn]: Error in callback for watcher "value": "TypeError: Cannot read property ‘indexOf‘ of undefined"
found in
---> <Tables>
<Card>
<Anonymous>
<Content>
<Layout>
<Content>
<Layout>... (1 recursive calls)
<Main> at src/components/main/main.vue
<App> at src/App.vue
<Root>
vue.runtime.esm.js?2b0e:1737 TypeError: Cannot read property ‘indexOf‘ of undefined
at eval (tables.vue?b476:216)
at Array.filter (<anonymous>)
at VueComponent.handleSearch (tables.vue?b476:215)
at VueComponent.value (tables.vue?b476:268)
at Watcher.run (vue.runtime.esm.js?2b0e:3229)
at flushSchedulerQueue (vue.runtime.esm.js?2b0e:2977)
at Array.eval (vue.runtime.esm.js?2b0e:1833)
at flushCallbacks (vue.runtime.esm.js?2b0e:1754)
原因:
tables的搜索功能,加载列名称的代码如下:
setDefaultSearchKey () {
this.searchKey = this.columns[0].key !== ‘handle‘ ? this.columns[0].key : (this.columns.length > 1 ? this.columns[1].key : ‘‘)
}
列属性key非‘handle‘时,为搜索项目,当加入type属性,搜索就报错
解决方法:
{type:‘index‘,key:‘handle‘,title: ‘序号‘, width: 60, align: ‘center‘ }
即添加key:‘handle‘,问题完美解决
基于iview admin二次开发,tables列描述数据对象type属性使用注意事项
原文:https://www.cnblogs.com/jingsichen/p/10537025.html