首页 > 其他 > 详细

基于iview admin二次开发,tables列描述数据对象type属性使用注意事项

时间:2019-03-15 15:04:46      阅读:494      评论:0      收藏:0      [点我收藏+]

现象:

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!