gpt4 book ai didi

reactjs - WebStorm 上的 %PUBLIC_URL% 编辑器警告

转载 作者:行者123 更新时间:2023-12-03 16:27:55 28 4
gpt4 key购买 nike

带有 create-react-app 的 WebStorm 在 /public/index.html 中有文件,到 /public 的文件夹路径标记为 %PUBLIC_URL% .

找不到目录%PUBLIC_URL%因为它不存在,也不应该存在。

除了用 <!--suppress HtmlUnknownTarget --> 抑制错误之外, 有没有办法在 Webstorm 中为目录变量设置别名,如 %PUBLIC_URL% , 到 /public 的根路径在开发中没有编辑器错误?

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>

最佳答案

这篇文章似乎对此提供了更多见解:
https://medium.com/@jenniferdobak/the-public-folder-and-favicons-in-create-react-app-8dc2cc1d492b

This is a good time to address that funky looking %PULIC_URL% tag. Remember the ‘escape hatch’ React provides in case we put assets in the public folder? During the build, assets prefixed with the %PULIC_URL% tag will be recognized and complied. However this is NOT best practice and should be used only when necessary.


因此,在大多数情况下,您可以将 %PUBLIC_URL% 替换为 public 之类的内容,当然,这取决于您如何构建 React 项目。

关于reactjs - WebStorm 上的 %PUBLIC_URL% 编辑器警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50670349/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com