动态StyleUrl Angular 7

时间:2018-11-12 07:09:36

标签: angular typescript less angular7

哪种方法更适合角度7中的动态载荷样式 我使用这种方式的例子,但不能在版本7角 另外,此代码在较低的Angular 7版本中有效 帮帮我,谢谢

function theme(): string[] {
  // return ['./app.component.less'] >> not find
     return ['/app.component.less']
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: theme()
})

1 个答案:

答案 0 :(得分:0)

您必须提供styleURL的链接。在这里,我更新您的代码。请看看。

有关更多详细信息,请使用给定链接Angular7 Component Styles

function theme(): string[] {
  // return ['./app.component.less'] >> not find
     return ['/app.component.less']
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})