dart - 如何使NgComponent样式在Chrome/Firefox中工作,

标签 dart angular-dart

我有一个 Angular 组件

@NgComponent(
  selector: 'mycomponent',
  template: r''' ... some markup ...''',
  cssUrl: 'packages/myapp/components/mycomponent/mycomponent.css'
)
class MyComponent {
}
mycomponent.css包含许多样式,例如

:host div.someclass {
  border: 3px solid #aeaeae;
  /*... and some other */
}
index.html包含

<head>
    <title>MyApp</title>
    <script src="packages/shadow_dom/shadow_dom.debug.js"></script>
    <!-- shadow_dom.min.js doesn't work with firefox
         https://github.com/Polymer/ShadowDOM/issues/372 
       <script src="packages/shadow_dom/shadow_dom.min.js"> -->
</head>

在Dartium中可以正常工作。

当我在Chrome或Firefox中运行pub build并运行结果时,所有样式都将被忽略
Inspect元素在Chrome和Firefox中显示,包含所有样式的样式标签已添加到<mycomponent>标记的第一个子项中。

我想在Dartium以外的其他浏览器中实现此功能的目的是什么?

最佳答案

我认为您可能在pubspec文件(shadow_dom: any)中缺少对影子dom的依赖。您还需要在html中添加脚本(<script src="packages/shadow_dom/shadow_dom.min.js"></script>)。我尝试从angular.dart.tutorial项目(特别是Chapter_04)运行示例,它在Chrome和FF中运行良好。

关于dart - 如何使NgComponent样式在Chrome/Firefox中工作,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21800149/

相关文章:

dart - TabController 构造函数中的 `vsync` 属性

angularjs - 服务器是否需要使用Polymer.dart和/或Angular.Dart运行某些CLIENT端DART应用程序?

dart - Material 扩展面板的数据驱动内容

dart - 装饰器(范围)/监视功能未调用

flutter - 在 flutter 中格式化按钮和嵌套ListView

firebase - Flutter:如何使用先前的状态更新 Firestore 中的数据

javascript - 在 Flutter 的 html 文件中使用 js 文件

view - AngularDart: “logical pages”和 View 是一对一或一对多或什么?

dart - AngularDart的角度组件的应用布局

dart - Flutter 中的 final/const 热潮是怎么回事?