设置StyleUrls可变我有一个ts
文件中像这样如何在角2
export const environment = {
production: false,
profile : './test/test.css'
};
我想进口environment.profile
,并设置它,这样我可以在StyleUrls使用它像
import { Component, OnInit } from '@angular/core';
import { TranslateService } from "@ngx-translate/core";
import {environment} from "../../environments/environment";
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: [environment.profile]
})
但我得到的错误:
Error: Cannot find module "." main.bundle.js:250:62 webpackMissingModule http://localhost:4200/main.bundle.js:250:62 ../../../../../src/app/header/header.component.ts http://localhost:4200/main.bundle.js:250:29 webpack_require http://localhost:4200/inline.bundle.js:55:12 ../../../../../src/app/app.module.ts http://localhost:4200/main.bundle.js:71:83 webpack_require http://localhost:4200/inline.bundle.js:55:12 ../../../../../src/main.ts http://localhost:4200/main.bundle.js:291:74 webpack_require http://localhost:4200/inline.bundle.js:55:12 [2] http://localhost:4200/main.bundle.js:309:18 webpack_require http://localhost:4200/inline.bundle.js:55:12 webpackJsonpCallback http://localhost:4200/inline.bundle.js:26:23 http://localhost:4200/main.bundle.js:1:1 [WDS] Warnings while compiling. vendor.bundle.js:13428:10 ./src/app/header/header.component.ts 32:17-45 Critical dependency: the request of a dependency is an expression vendor.bundle.js:13493:4
我不知道如何解决它可以someo ne帮我
它指的是我的css的确切路径 – user2843943
你可以尝试把一个硬编码的字符串,而不是变量? (只是为了确认问题是什么) –
工作正常 – user2843943