Home>Article>Web Front-end> Solving problems encountered when using async and await in vue (with examples)
The content of this article is about solving problems encountered when using async and await in vue (with examples). It has certain reference value. Friends in need can refer to it. Hope it helps.
I have been working on some new things recently, and I encountered an async/await pit today;
Because I am not using the official scaffolding of vue, I encountered this problem:
await is a reserved word
Such a warning, I guess it should be due to the lack of relevant parsers.
Then after removing await, an async problem appeared again:
Okay, I can only Google it.
After finding relevant information:
Install babel-plugin-transform-runtime and babel-runtime, and add: "plugins":["transform-runtime to the .babelrc file "], this solves the problem
npm i babel-plugin-transform-runtime --save-dev npm i babel-runtime --save
There is a .babelrc file in the project root directory, add a code:
"plugins":["transform-runtime"]
becomes the following:
Restart the project and solve the problem
The above is the detailed content of Solving problems encountered when using async and await in vue (with examples). For more information, please follow other related articles on the PHP Chinese website!