【问题标题】:How to resolve "Adjacent JSX elements must be wrapped in an enclosing tag" issue in Vue.js如何解决 Vue.js 中的“相邻 JSX 元素必须包含在封闭标记中”问题
【发布时间】:2019-06-06 00:12:18
【问题描述】:

我正在 WebStorm 中运行一个 Vue.js 项目。出于某种原因,我收到了这个 ESLint 错误:

ESLint: 解析错误:相邻的 JSX 元素必须用封闭标签包裹

以下代码:

<template>
    <div>

    </div>

</template>

<script>

正如您在屏幕截图中看到的,这发生在 &lt;script&gt; 开始标记上。

关于 React 项目有重复的问题,但他们的答案不适用于我的 Vue 项目。

有人可以帮忙吗?任何帮助将不胜感激。

这是我的 .eslintrc.js:

module.exports = {
    "extends": ["vue", "standard"],
    "plugins": [
      "import",
      "vue"
    ],
};

【问题讨论】:

标签: vue.js webstorm eslint


【解决方案1】:

将'plugin:vue/recommended' 添加到 .eslintrc.js 解决了我的问题。 现在我的 .eslintrc.js 看起来像这样:

module.exports = {
    "extends": ["vue", "standard", "plugin:vue/recommended"],
    "plugins": ["import", "vue"],
};

【讨论】:

  • 有没有办法一次性安装所有依赖项?
猜你喜欢
  • 2019-06-14
  • 2018-05-26
  • 2019-11-06
  • 2017-12-30
  • 2019-01-12
  • 2020-06-14
  • 2019-09-29
  • 2021-04-05
相关资源
最近更新 更多