Skip to content

Why the 'asyncData' function doesn't work? #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
menglingbujie opened this issue Dec 9, 2019 · 3 comments
Closed

Why the 'asyncData' function doesn't work? #241

menglingbujie opened this issue Dec 9, 2019 · 3 comments

Comments

@menglingbujie
Copy link

Describe the bug
Hey guys, I don't understand why the 'asyncData' function doesn't work?
Anybody know that?

In class api
asyncData(){
console.log("===asyncData"); // no log
}
created(){
console.log("===created"); // display "===created"
}

@menglingbujie
Copy link
Author

I understand

@component({
asyncData(){ // here is ok

}
})

export default class A extends Vue{
}

@kevinmarrec
Copy link
Contributor

kevinmarrec commented Dec 9, 2019

@menglingbujie You can use nuxt-property-decorator over vue-property-decorator if you want to use Nuxt component options directly in the class instead of component options :

#58 (comment)

https://github.com/nuxt-community/nuxt-property-decorator/blob/master/src/nuxt-property-decorator.ts#L20

Ultimately, you can also register hooks like the link above on your own through a Nuxt plugin.

@menglingbujie
Copy link
Author

@kevinmarrec Cool~~~ Thx~!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants