Har*_*rle 11 intellij-idea webstorm reactjs create-react-app
带有 create-react-app 的 WebStorm 在/public/index.html文件中有一个文件夹路径/public标记为%PUBLIC_URL%.
它找不到目录,%PUBLIC_URL%因为它不存在,也不应该存在。
除了使用 抑制错误之外<!--suppress HtmlUnknownTarget -->,Webstorm 中是否还有一种方法可以将目录变量(如 , )别名%PUBLIC_URL%到/publicfor 开发中没有编辑器错误的根路径?
<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>
Run Code Online (Sandbox Code Playgroud)
小智 1
本文似乎对此提供了更多见解:
\n https://medium.com/@jenniferdobak/the-public-folder-and-favicons-in-create-react-app-8dc2cc1d492b
\n\n现在是解决那个看起来很时髦的 %PULIC_URL% 标签的好时机。还记得 React 提供的 \xe2\x80\x98escape Hat\xe2\x80\x99 以防我们将资源放入公共文件夹吗?在构建过程中,将以 %PULIC_URL% 标签为前缀的资源将被识别和编译。然而,这不是最佳实践,仅应在必要时使用。
\n
因此,在大多数情况下,您可以将%PUBLIC_URL%替换为public之类的内容之类的内容,但是当然,这取决于您如何构建 React 项目。
\n| 归档时间: |
|
| 查看次数: |
1221 次 |
| 最近记录: |