Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在vue-tables-2中动态填充listColumns?_Javascript_Vue.js_Vue Tables 2 - Fatal编程技术网

Javascript 如何在vue-tables-2中动态填充listColumns?

Javascript 如何在vue-tables-2中动态填充listColumns?,javascript,vue.js,vue-tables-2,Javascript,Vue.js,Vue Tables 2,假设我有一个通过道具可用的类别名称数组 在vue-tables-2中,如何在列表列选项中动态填充类别过滤器 listColumns: { type: [{ id: 1, text: 'User' }, { id: 2, text: 'Admin' }], category: function () { this.categories.map((cat, index) => { return { id: index, text: c

假设我有一个通过道具可用的类别名称数组

vue-tables-2中,如何在
列表列
选项中动态填充
类别
过滤器

listColumns: {
  type: [{
    id: 1,
    text: 'User'
  },
  {
    id: 2,
    text: 'Admin'
  }],
  category: function () {
    this.categories.map((cat, index) => { return { id: index, text: cat } })
  }
}
这样做会返回以下错误:

[Vue warn]: Error in render: "TypeError: _this.opts.listColumns[column].filter is not a function"

您可以在选项中插入道具

options: {
  filterByColumn: true,
    listColumns: {
        type: this.categories
    }
}