vue-api-query
vue-api-query copied to clipboard
How to add default attributes
What is the correct way of adding default attributes? Maybe we can also include in the documentation. Currently this is how I did it. Also please let me know if my solution is valid or correct. Thanks!
export default class Model extends BaseModel {
constructor(...attributes) {
super()
if (attributes.length) {
Object.assign(this, this.defaultAttributes(), ...attributes)
}
}
defaultAttributes() {
return {}
}
}
export default class User extends Model {
defaultAttributes() {
return {
selected: false // useful for checkbox or selection state
}
}
}