react js 代码显示红色突出显示,即使它在 vs code 中的正确语法也是如此

问题描述 投票:0回答:1

enter image description herei am getting red code highlight in vs code even correct syntx and code is also working  .. i try to solve this by changing themes & turn off all extantion but nothing fix .and its very annoying to work with that. please help me

我正在尝试在 vs 代码中使用 React 应用程序。但是当我在返回语句中使用带有多个子项的 html 标记时,它显示突出显示的红色。在返回语句中使用大括号

reactjs visual-studio-code syntax-error syntax-highlighting
1个回答
0
投票

你应该像这样在顶部导入 React

   import React from 'react';

我认为这解决了问题

如果这不能解决您的问题,那么我建议卸载 vs code 下载最新版本,然后安装扩展,如 ESLint、ES7+ React/Redux/React-Native 片段,或者尝试不使用任何扩展,如果您已经在您的机器上全局安装了 react卸载它然后重新安装反应

© www.soinside.com 2019 - 2024. All rights reserved.