简体   繁体   English

为什么我在不使用 JSX 时会收到有关 JSX 的警告?

[英]Why do I get a warning about JSX when I do not use JSX?

I have a Vue.js component file (the framework is Quasar) where, in <template> I have the following block of code:我有一个 Vue.js 组件文件(框架是 Quasar),其中,在<template>我有以下代码块:

<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:此代码被 TypeScript 突出显示为错误:

在此处输入图像描述

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.我根本不使用 React,只使用 Vue.js、Quasar 和 TypeScript。 <q-btn> is the only element that is highlighted as errornous, any other element (generic or Quasar) is fine. <q-btn>​​ 是唯一被突出显示为错误的元素,任何其他元素(通用或 Quasar)都可以。

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:通过在tsconfig.json文件中的compilerOptions条目中添加"jsx": "preserve",也可以避免此问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我不断收到“JSX 未定义 no-undef” - Why do I keep getting "JSX is not defined no-undef" 当我在 nextjs 的 jsx 中使用 if 时,类名会感到困惑 - classname get confused when i use if in jsx in nextjs 尝试使用 Reactstrap 卡时,我收到警告:React.jsx:类型无效 - 需要字符串(用于内置组件)或类/函数? - When trying to use Card of Reactstrap I get Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function? 如何使用 JSX 导入模块? - How do I import modules with JSX? 如何将 TSX 转换为 JSX - How do I convert TSX to JSX 我什么时候应该特别使用.jsx 和.js? - When should I use .jsx and .js particularly? 如何在React中访问另一个jsx文件中的一个jsx文件的数据? - How do I access data of one jsx file in the other jsx file in React? Photoshop:如何在 Photoshop 中从另一个 JSX 脚本运行/调用 JSX 脚本? - Photoshop: How do I run / call a JSX script from another JSX script in Photoshop? 为什么嵌套JSX需要花括号,即使没有它也可以使用 - Why do I need curly braces for nested JSX, even if it is working without it 我如何在ReactJs.Net的JSX文件中使用自定义ReactJs组件 - How do I use a custom ReactJs component inside my JSX file from ReactJs.Net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM