Undefined function in the Custom Directive

Posted 2 years ago by gabrielbuzzi

I'm trying to understand why javascript is not finding doSomething as a function. Some help?

Using Vue 2.0

Error

Uncaught TypeError: Cannot read property 'doSomething' of undefined

My custom directive

directives: {
        ajaxSubmit: {
            bind (el, binding, vNode) {
                this.doSomething()
            },

            doSomething () {
                console.log('doing something')
            }
        }
    }

Please sign in or create an account to participate in this conversation.