Home>Article>Web Front-end> Solving problems encountered when using async and await in vue (with examples)

Solving problems encountered when using async and await in vue (with examples)

不言
不言 forward
2018-11-24 14:24:12 9940browse

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:

Solving problems encountered when using async and await in vue (with examples)

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:

Solving problems encountered when using async and await in vue (with examples)

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!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete