gpt4 book ai didi

css - 如何在 Aurelia 中包含额外的 CSS 文件?

转载 作者:行者123 更新时间:2023-11-28 14:12:58 24 4
gpt4 key购买 nike

我有一个应用程序可以打开一个包含内容的新窗口。我需要那个窗口的特殊 CSS。

打开窗口的代码是这样的:

var Printwindow = window.open("","","width=360,height=188");
var cssFile = Printwindow.document.createElement("link");
cssFile.rel = "stylesheet";
cssFile.type = "text/css";
cssFile.href = "../../content/label.css";

Printwindow.document.write("<head>" + cssFile.outerHTML + "</head><body onload='window.print();'>" + this.label.innerHTML + "</body>");
Printwindow.document.close();
Printwindow.focus();

当我在本地主机上运行时,label.css 就在那里。但是当我构建它并将它部署到服务器时它丢失了。我如何将这个 label.css 包含在包中以便它可以找到它?

最佳答案

如果你正在使用 webpack,你应该引用该文件以便 webpack 找到它:

cssFile.href = PLATFORM.moduleName("../../content/label.css");

并导入 PLATFORM:

import {PLATFORM} from 'aurelia-pal';

希望对您有所帮助。

关于css - 如何在 Aurelia 中包含额外的 CSS 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56270828/

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