下面的代码是为样式定义的.
<!-- for mobile -->
<link rel="stylesheet" href="/dist/css/mobile.css">
<!-- for desktop -->
<link rel="stylesheet" href="/dist/css/desktop.css">
Run Code Online (Sandbox Code Playgroud)
我想按条件将上面的文件添加到'src/index.html'中的<head>.
如何为每个设备应用css文件?
如您所知,我不能在'index.html'中使用'条件'代码.
请注意,我不会使用以下方法.
// in angular-cli.json
"apps": [
{
"root": "src",
"index": "index.html",
"styles": [
"/dist/css/mobile.css",
"/dist/css/desktop.css"
]
}
]
// in component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: '/dist/css/mobile.css'
})
Run Code Online (Sandbox Code Playgroud)
我期待着你的建议.
谢谢.