Ionic-如何从node_模块导入SCS或css文件?
我想在我的组件中导入此css或scss文件: 无论我尝试什么都不起作用 这是我已经尝试过的:Ionic-如何从node_模块导入SCS或css文件?,css,angular,ionic-framework,ionic3,Css,Angular,Ionic Framework,Ionic3,我想在我的组件中导入此css或scss文件: 无论我尝试什么都不起作用 这是我已经尝试过的: @Component({ selector: 'videoPlayer', template: ``, styleUrls: [ //see below what I have tried to put here. ] }) “../../../node_模块/plyr/dist/plyr.css” 未处理的承诺拒绝:加载../../../no
@Component({
selector: 'videoPlayer',
template: ``,
styleUrls: [
//see below what I have tried to put here.
]
})
“../../../node_模块/plyr/dist/plyr.css”
“../../../node_模块/plyr/dist/plyr.css”
- 我在没有
的情况下尝试了这两个URL,但它没有加载或给出错误。/../../../
- 我尝试了两个没有
node\u模块的URL,但都是从
开始的。给出与上述相同的错误~plyr/
- 我把我的
文件放在这里,尝试了这个component.scss
@import“~plyr/dist/plyr.css”代码>
- 如果没有扩展名,则会出现错误,文件找不到或无法访问
@import“~plyr/src/sass/plyr.scss”代码>还提供文件未找到或无法访问的错误
- 没有扩展名也会产生同样的错误
- 复制它并将其放置在您的资产文件夹中
- 使用链接标记在index.HTML中定义它
- 任何全局导入它的东西,我只希望它位于特定组件中
样式URL
属性,请从组件的scss文件导入scss:
your-component {
@import '../../../node_modules/plyr/src/sass/plyr';
}
它将被编译成CSS,并像您手动添加到组件的scss文件中的任何scss一样添加前缀。您不能像
@import'~plyr/src/sass/plyr'那样编写它吗代码>从scss文件中的?
your-component {
@import '../../../node_modules/plyr/src/sass/plyr';
}