[英]How to import my external Style or JS files in Astro Layout
Does anyone know how I'll be able to import my external CSS and JS files into Astro's new version?有谁知道如何将我的外部 CSS 和 JS 文件导入到 Astro 的新版本中? I tried:
我试过了:
<link rel="stylesheet" href={Astro.resolve('../styles/style.css')}>
But it's not workings anymore after Astro's new 1.0 Update launch.但在 Astro 新的 1.0 更新发布后,它不再有效。
Astro.resolve
has been deprecated as you can see in detail in the documentation . Astro.resolve
已被弃用,您可以在文档中看到详细信息。
Summary of the recommended ESM Import method:推荐的 ESM 导入方法总结:
.css
file inside the src/
directory.css
文件放在src/
目录中.astro
file:.astro
文件:---
// Example: Astro will include and optimize this CSS for you automatically
import './style.css';
---
<html><!-- Your page here --></html>
If you place your style sheet in the public
folder, you can simply import it using:如果您将样式表放在
public
文件夹中,您可以简单地使用以下命令导入它:
<link rel="stylesheet" href="index.css" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.