Home > Web Front-end > JS Tutorial > body text

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

不言
Release: 2018-11-24 14:28:48
forward
10018 people have browsed it

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
Copy after login

There is a .babelrc file in the project root directory, add a code:

"plugins":["transform-runtime"]
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template