Vuetable-2: Uncaught TypeError: this.fields.forEach is not a function(…)

Created on 25 Nov 2016  Â·  4Comments  Â·  Source: ratiw/vuetable-2

Hi, I am using vue2 with vuetable-2, i follow vuetable documentation but i got this, i tried to copy paste the example but the error still occurred..

Uncaught TypeError: this.fields.forEach is not a function(…)

Please help me, i log "this.fields" is an object instead of array

duplicate

Most helpful comment

If you using vee-validate plugin you can init it like this - Vue.use(VeeValidate, {fieldsBagName: 'formFields'})

All 4 comments

@hitoz Can you please provide more info? Please also make sure that you are really using vuetable-2, not vue-tables-2.

yes, i am using this package
"vuetable-2": "^0.9.2",
`normalizeFields: function() {
if (typeof(this.fields) === 'undefined') {
this.warn('You need to provide "fields" prop.')
return
}

  var self = this
  var obj
  this.fields.forEach(function(field, i) {
    if (typeof (field) === 'string') {
      obj = {
        name: field,
        title: self.setTitle(field),
        titleClass: '',
        dataClass: '',
        callback: null,
        visible: true,
      }
    } else {
      obj = {
        name: field.name,
        title: (field.title === undefined) ? self.setTitle(field.name) : field.title,
        sortField: field.sortField,
        titleClass: (field.titleClass === undefined) ? '' : field.titleClass,
        dataClass: (field.dataClass === undefined) ? '' : field.dataClass,
        callback: (field.callback === undefined) ? '' : field.callback,
        visible: (field.visible === undefined) ? true : field.visible,
      }
    }
    Vue.set(self.fields, i, obj)
  })
},`

i got error from this line, this.fields.forEach(function(field, i) {
i try to log "this.fields" its not an array, its a FieldBag Object..

looks like it don't receive the parameter value or somewhere is overriding the variable value

@hitoz I think your problem is the same as this

If you using vee-validate plugin you can init it like this - Vue.use(VeeValidate, {fieldsBagName: 'formFields'})

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mondul picture mondul  Â·  3Comments

Geowan picture Geowan  Â·  3Comments

anselmobattisti picture anselmobattisti  Â·  5Comments

flyingcoder picture flyingcoder  Â·  3Comments

hanxue picture hanxue  Â·  3Comments