当我不使用JSX时,为什么要警告JSX?

发布于 2025-02-05 11:20:34 字数 959 浏览 4 评论 0原文

我有一个vue.js组件文件(框架为quasar),其中< template> i具有以下代码块:

<q-btn
 color="green"
 label="save & continue editing"
 @click="saveCase()"
/>

它是其他代码的一部分。

该代码通过打字稿强调为错误:

”“在此处输入图像描述”

错误的详细信息:

[{
    "resource": "/D:/dev-pro/secops-cases/front/src/components/Case.vue",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": "17004",
    "severity": 8,
    "message": "Cannot use JSX unless the '--jsx' flag is provided.",
    "source": "ts",
    "startLineNumber": 108,
    "startColumn": 11,
    "endLineNumber": 112,
    "endColumn": 13
}]

这是什么意思?我根本不使用React,只有VUE.JS,类星体和打字稿。 &lt; q-btn&gt;是唯一突出显示为错误的元素,任何其他元素(通用或Quasar)都可以。

I have a Vue.js component file (the framework is Quasar) where, in <template> I have the following block of code:

<q-btn
 color="green"
 label="save & continue editing"
 @click="saveCase()"
/>

It is part of other code.

This code is highlighted as an error by TypeScript:

enter image description here

Details of the error:

[{
    "resource": "/D:/dev-pro/secops-cases/front/src/components/Case.vue",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": "17004",
    "severity": 8,
    "message": "Cannot use JSX unless the '--jsx' flag is provided.",
    "source": "ts",
    "startLineNumber": 108,
    "startColumn": 11,
    "endLineNumber": 112,
    "endColumn": 13
}]

What does it mean? I do not use React at all, just Vue.js, Quasar and TypeScript. <q-btn> is the only element that is highlighted as errornous, any other element (generic or Quasar) is fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2025-02-12 11:20:34

尝试添加关闭标签以避免此警告:

<q-btn
 color="green"
 label="save & continue editing"
 @click="saveCase()"
></q-btn>

也可以通过将“ JSX”:“ Preserve”,添加到compileroptions tsconfig中的条目来避免此问题。 .json文件:

{
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "strict": true,
    "jsx": "preserve",
  }
}

Try to add a closing tag to avoid this warning :

<q-btn
 color="green"
 label="save & continue editing"
 @click="saveCase()"
></q-btn>

This issue can be avoided also by adding "jsx": "preserve", to the compilerOptions entry in tsconfig.json file :

{
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "strict": true,
    "jsx": "preserve",
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文