yunsan-pc/public/README.md

42 lines
999 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Public 目录说明
此目录下的文件在构建时会原样复制到输出目录,可通过根路径直接访问。
## 目录结构
```
public/
├── imgs/ # 静态图片资源
│ ├── logo.png
│ ├── bg.jpg
│ └── icons/
├── js/ # 第三方JS库不通过npm管理的
│ └── external-lib.js
├── fonts/ # 字体文件
│ └── custom-font.ttf
└── data/ # 静态数据文件
└── config.json
```
## 使用方式
在代码中直接通过根路径引用:
```html
<!-- HTML中 -->
<img src="/imgs/logo.png" alt="logo">
<link rel="stylesheet" href="/fonts/font.css">
<!-- Vue模板中 -->
<img :src="'/imgs/logo.png'" alt="logo">
<!-- 获取数据 -->
fetch('/data/config.json')
```
## 注意事项
1. 此目录下的文件不会被webpack/vite处理会直接复制
2. 适合放置不需要构建处理的静态资源
3. 大型图片、字体文件建议放这里