转到 .jsx 的定义不起作用
Go to definition for .jsx does not work
我在 Visual Studio 代码中使用 es6 语法,当我导入普通文件时,然后我可以单击 F12(转到定义),它工作得很好。问题是组件(从 .jsx 文件导入)根本不起作用(单击 go to definition
时没有任何反应)。有人知道如何修复它吗?
P.S。我有这样的 jsconfig.json
以允许正确转到普通 .js 文件的定义:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules"
]
}
尽管您可以从其中一条评论中提到的 github issues 中找到解决方案,但我想让 SO 用户更容易使用。引自 Github 问题页面:
easy workaround is to add the compilerOption "jsx": "preserve" (or
"jsx": "react" or "jsx": "react-native")
jsconfig.json:
{
"compilerOptions": {
"jsx": "react"
}
}
我在 Visual Studio 代码中使用 es6 语法,当我导入普通文件时,然后我可以单击 F12(转到定义),它工作得很好。问题是组件(从 .jsx 文件导入)根本不起作用(单击 go to definition
时没有任何反应)。有人知道如何修复它吗?
P.S。我有这样的 jsconfig.json
以允许正确转到普通 .js 文件的定义:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules"
]
}
尽管您可以从其中一条评论中提到的 github issues 中找到解决方案,但我想让 SO 用户更容易使用。引自 Github 问题页面:
easy workaround is to add the compilerOption "jsx": "preserve" (or "jsx": "react" or "jsx": "react-native")
jsconfig.json:
{
"compilerOptions": {
"jsx": "react"
}
}