需要在多个 Angular 元素之间共享一些 CSS 和 TS。有办法吗?复制粘贴看起来不太适合这个目的。
最佳答案
对于每个元素,您都可以尝试将其添加到您的 angular.json 中。在样式部分,通常还有来自您的节点包的其他样式。
"styles": [
"path/to/style/style.scss", // Your custom style
"node_modules/font-awesome/css/font-awesome.css" //exemple of package style
]
编辑: 如果你需要加载外部 css。 您可以使用您在第一篇文章的评论中提到的使用 src 应用程序文件夹中 index.html 中的“链接”。对于每个 ng 元素。希望它能符合您的要求。
<link rel="stylesheet" type="text/css" href="server/with/css/custom.css">
关于css - 跨元素共享 css 和 ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53149777/