预期“样式”为角度为5的字符串数组

时间:2018-07-26 15:54:19

标签: angular webpack angular5

我收到此错误:

Uncaught Error: Expected 'styles' to be an array of strings.
    at assertArrayOfStrings (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:1620)
    at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:10490)
    at CompileMetadataResolver.loadDirectiveMetadata (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:10413)
    at eval (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:22806)
    at Array.forEach (<anonymous>)
    at eval (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:22805)
    at Array.forEach (<anonymous>)
    at JitCompiler._loadModules (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:22802)
    at JitCompiler._compileModuleAndComponents (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:22780)
    at JitCompiler.compileModuleAsync (webpack-internal:///./node_modules/@angular/compiler/fesm5/compiler.js:22740)

通常我是将字符串数组传递给Component:

@Component({
  selector: 'Modulo',
  templateUrl: './Moduloo.component.html',
  styleUrls: ['Modulo.component.css'],
  encapsulation: ViewEncapsulation.None
})

即使删除styleUrls仍然无法正常工作,但在NG2下我有相同的代码,可以正常工作。

我在互联网上搜索了解决方案;人们正在谈论修改Webpack配置,但是我想知道为什么这个问题适用于某些组件而不适用于某些组件。

0 个答案:

没有答案