gpt4 book ai didi

syntax - WebStorm/JetBrains : cannot recognize es6 syntax in a . vue文件

转载 作者:搜寻专家 更新时间:2023-10-30 22:22:18 27 4
gpt4 key购买 nike

我在 Webstorm 中使用 vue 框架,使用 ES6 语法。

我已经安装了 vue-for-idea 插件,如果我使用纯 ES5 语法,一切都会很顺利。

但是代码的ES6部分似乎还没有被识别,并被高亮警告:

例如这段代码:

<script>
import { DeUser } from '../api/resource';

export default{

.....

ready() {
// Warned by: The expression statement is not assignment in this code
DeUser.get().then((resp) => {
console.log(resp);
});
},
</script>

我完美地运行了我的项目并得到了正确的resp,但是WebStorm 提示我表达式语句不是赋值,我该如何解决?

最佳答案

终于有了一个简单的解决方案,在你的.vue文件,只需添加 lang="babel"作为 <script> 中的一个属性标签:

<template>
<!-- markup content -->
</template>

<script lang="babel">
</script>

关于syntax - WebStorm/JetBrains : cannot recognize es6 syntax in a . vue文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38135966/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com