我正在研究angular2“2.0.0-rc.1”
但是zoneJS给出了以下错误
但是zoneJS给出了以下错误
Error: Uncaught (in promise): Expected 'styles' to be an array of strings. at resolvePromise (zone.js:538) at zone.js:515 at ZoneDelegate.invoke (zone.js:323) at Object.ngzoneImpl.inner.inner.fork.onInvoke (eval at <anonymous> (vendor.js:335),<anonymous>:45:41) at ZoneDelegate.invoke (zone.js:322) at Zone.run (zone.js:216) at zone.js:571 at ZoneDelegate.invokeTask (zone.js:356) at Object.ngzoneImpl.inner.inner.fork.onInvokeTask (eval at <anonymous> (vendor.js:335),<anonymous>:36:41) at ZoneDelegate.invokeTask (zone.js:355)
我的代码如下
let styles = require('./dashboard.css'); let template = require('./dashboard.html'); declare var zingchart:any; @Component({ selector: 'dashboard',directives: [ RouterLink,CORE_DIRECTIVES,FORM_DIRECTIVES ],template: template,styles: [ styles ] })
解决方法
试试这个:
let styles = String(require(‘./ dashboard.css’));
let styles = String(require(‘./ dashboard.css’));
它对我有用.由于样式需要字符串[],因此将样式解析为String().
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。