I use setup function in
export default class class_name extends Vue {
setup() {}
}
but it's not working?
Not sure if It'll help or not, but you should start by registering the hook,
Component.registerHooks([
'setup'
])
Not sure if It'll help or not, but you should start by registering the hook,
Component.registerHooks([ 'setup' ])
where i can place it? main.js right?
Yes, in main.js I've:
import Component from 'vue-class-component'
Component.registerHooks(['setup', 'beforeRouteUpdate', 'beforeRouteEnter', 'beforeRouteLeave'])
thank for your help :)
Seems the issue is resolved, if not, please reopen or create a new issue.
Remember to use the forum or the Discord chat to ask questions!
I have done the following:
main.js
import Component from 'vue-class-component';
// On why we do this visit: https://github.com/vuejs/composition-api/issues/136
Component.registerHooks(['setup']);
Then on my component:
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class MyComponent extends Vue {
setup() {
console.log('setup function executed');
}
}
But the console log never shows. Any idea?
If I move the setup method to the options it works:
@Component({ setup() { console.log('hello from setup') } })
Most helpful comment
Yes, in main.js I've: