Common CSS not applying when specifying platform specific

未关闭
#149 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
angular, typescript
领域
frontend, mobile

调研方向

从 issue 中链接的平台特定 CSS 指南开始,并使用 items.component.css、items.component.android.css、items.component.ios.css 和 items.component.ts 重现该行为。调查为什么公共样式表会解析为 Android 变体,然后验证共享的大写规则和每个平台特定的颜色规则是否会同时应用。

由索引模型根据 Issue 内容生成。

描述

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

{
  "name": "stackblitz-nativescript-angular",
  "main": "./src/main.ts",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "~19.0.0",
    "@angular/common": "~19.0.0",
    "@angular/compiler": "~19.0.0",
    "@angular/core": "~19.0.0",
    "@angular/forms": "~19.0.0",
    "@angular/platform-browser": "~19.0.0",
    "@angular/platform-browser-dynamic": "~19.0.0",
    "@angular/router": "~19.0.0",
    "@nativescript/angular": "^19.0.0",
    "@nativescript/core": "~8.8.0",
    "rxjs": "~7.8.0",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~19.0.0",
    "@angular/compiler-cli": "~19.0.0",
    "@nativescript/preview-cli": "^1.0.14",
    "@nativescript/stackblitz": "0.0.8",
    "@nativescript/tailwind": "^2.1.0",
    "@nativescript/types": "~8.8.0",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "~19.0.0",
    "tailwindcss": "~3.4.0",
    "typescript": "~5.6.0"
  }
}

Describe the bug
When adding platform specific css then the common.css is not being applied e.g: I have 3 css according to the docs: https://docs.nativescript.org/guide/styling#platform-specific-css

items.component.css
items.component.ios.css
items.component.android.css

When items.component.css is imported into the items.component.android.css then items.component.css rule aren't applied.

To Reproduce

Add 3 css

items.component.css
items.component.ios.css
items.component.android.css

Add styleUrl: 'items.component.css', into items.component.ts

Update items.component.html:

<ActionBar title="My App"> </ActionBar>

<GridLayout rows="*,*">
  <Label row="0" text="Test" class="test"></Label>
  <ListView row="1" [items]="itemService.items()">
    <ng-template let-item="item">
      <StackLayout [nsRouterLink]="['/item', item.id]">
        <Label [text]="item.name" class="text-lg text-gray-500 p-4"></Label>
      </StackLayout>
    </ng-template>
  </ListView>
</GridLayout>

Update 3 css file each with different rules:

items.component.css

.test {
  text-transform: uppercase;
}

items.component.android.css

.test {
  color: purple;
}

items.component.ios.css

.test {
  color: green;
}

Expected behavior

Expect thar the items.component.css rule be applied for Test word be in Uppercase but only color changes in ios and android correctly.

Sample project

Additional context

What I noticed is that it prints this in the console: resolving "/home/projects/nativescript-stackblitz-templates-7sgpxgkm/src/app/item/items.component.css" to "/home/projects/nativescript-stackblitz-templates-7sgpxgkm/src/app/item/items.component.android.css"

More info on this video as well: https://www.youtube.com/watch?v=v5g6irUI704

主要语言
TypeScript
星标
55
派生
13
平均合并
16 分钟
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NativeScript/angular 的其他 Issue

查看 NativeScript/angular 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。