I\'d like to group some of my Vue.js methods together in a sort of \"submethod\" class, but I only seem to be able to have single level methods.
For example, if I wanted
I had the same issue (the need of a namespace) while writing a Vue mixin. This answer doesn't directly address your case, but it could give a clue.
This is how I defined the mixin.
export default {
created () {
// How to call the "nested" method
this.dummy('init')
// Pass arguments
this.dummy('greet', {'name': 'John'})
},
// Namespaced methods
methods: {
dummy (name, conf) {
// you can access reactive data via `that` reference,
// from inside your functions
const that = this
return {
'init': function (conf) {
console.log('dummy plugin init OK')
},
'greet': function (conf) {
console.log('hello, ' + conf['name'])
}
}[name](conf)
}
}
}
PS: for an official solution, Evan You said no.