首页 > 解决方案 > Nativescript CSS - 错误:要求的第一个参数应该是字符串

问题描述

尝试为我的应用组件创建特定于平台的 CSS 时出现以下错误。我的 android.css 正在工作,但 common.css 没有。任何想法为什么?

JS: Error: /app.component.common.css does not start with /data/data/org.nativescript.portalestapp/files/app

JS: Error: Could not load CSS from /app.component.common.css: Error: require's first parameter should be string

我有以下文件:app.component.html

app.component.ts

app.component.common.css

app.component.android.css

app.component.ios.css

app.component.ts :

@Component({
    selector: "ns-app",
    moduleId: module.id,
    templateUrl: "app.component.html",
    styleUrls: ["./app.component.css"]
})

app.component.common.css :

.page{
    background-color: #F4F5F7;
    font-family:Poppins-Regular, Poppins
}

.custom-action-bar {
    background-color:transparent;
}

app.component.android.css :

@import "/app.component.common.css";

.page {
    background-color: #fffffffa;
}

标签: cssangularnativescriptnativescript-angular

解决方案


page{
    background-color: #F4F5F7;
    font-family:Poppins-Regular, Poppins
}

custom-action-bar {
    background-color:transparent;
}

您的第一个条目必须是一个字符串


推荐阅读