漂亮的搞砸了jsx片段 [英] prettier messes up jsx fragments

查看:78
本文介绍了漂亮的搞砸了jsx片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function App() {
    
      return (
       <>
        <
        Navbar / >
        <
        Users / >
       </>
      );
    }

点击ctrl并将此更改保存到

on hitting ctrl+Save this changes to

function App() {

  return ( <
    >
    <
    Navbar / >
    <
    Users / >
    <
    />
  );
}

当我将鼠标悬停在该片段上时,它会显示"JSX片段没有相应的结束标记".

when i hover over the fragment it says "JSX fragment has no corresponding closing tag."

我尝试再次安装更漂亮的产品,对您没有帮助

i tried installing prettier again ,didn't help

推荐答案

您必须安装 Prettier插件并禁用 beautify 插件或其他任何预先设置的代码格式化程序-安装在VS代码中.

You have to install the Prettier plugin and disable beautify plugin or any other code formatter you have pre-installed in the VS code.

这可以帮助您解决当前问题.发生这种情况的原因是,两个插件的工作方式不同,并且两个插件都保持启用状态,这使我们在保存时可以使用此格式.禁用美化并安装Prettier插件有助于我们实现所需的输出.

This may help you resolve your current issue. This happens due to the fact that both plugins work differently and keeping both enabled refects us with this formate on save. Disabling beautify and installing the Prettier plugin helps us in achieving the required output.

您可以找到Prettier插件(此处).

You can find the Prettier plugin (here).

这篇关于漂亮的搞砸了jsx片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆