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
@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'})
Most helpful comment
If you using vee-validate plugin you can init it like this -
Vue.use(VeeValidate, {fieldsBagName: 'formFields'})