Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 自定义组件的动态创建_Dart_Dart Polymer - Fatal编程技术网

Dart 自定义组件的动态创建

Dart 自定义组件的动态创建,dart,dart-polymer,Dart,Dart Polymer,我正在尝试动态创建我创建的自定义组件的实例。我认为正确的方法是使用newelement.tag('custom-component'),但这会为我生成以下stacktrace: method not found: 'constructor' on null my_component_test.dart.browser_test.dart.js 21834:17 J.$index$asx my_component_test.dart.browser_test.dart.js 22460:

我正在尝试动态创建我创建的自定义组件的实例。我认为正确的方法是使用
newelement.tag('custom-component'),但这会为我生成以下stacktrace:

method not found: 'constructor' on null
  my_component_test.dart.browser_test.dart.js 21834:17  J.$index$asx
  my_component_test.dart.browser_test.dart.js 22460:14  <fn>
  unparsed                                              my_component_test.dart.browser_test.dart.js 22583:42  Isolate.prototype.(anonymous function)
  my_component_test.dart.browser_test.dart.js 16549:24  dart._setUpPropertyChanged
  my_component_test.dart.browser_test.dart.js 16521:28  $async$initPolymer
  my_component_test.dart.browser_test.dart.js 3319:13   _wrapJsFunctionForAsync_closure._captured_protected_1
  my_component_test.dart.browser_test.dart.js 4292:14   _wrapJsFunctionForAsync_closure.dart._wrapJsFunctionForAsync_closure.call$1
  my_component_test.dart.browser_test.dart.js 5945:18   dart._rootRunUnary
  my_component_test.dart.browser_test.dart.js 8620:41   _CustomZone.dart._CustomZone.runUnary$2
  my_component_test.dart.browser_test.dart.js 6906:80   _Future__propagateToListeners_handleValueCallback.dart._Future__propagateToListeners_handleValueCallback.call$0

我的设置中可能存在什么问题?如果我禁用检查,组件似乎已正确实现并注册,因为它可以正常工作。

我可以在运行测试时重现错误消息,而不使用
pub-service

使用
pubspec.yaml
文件从目录运行

pub serve test
(它应该打印在端口8080上侦听) 然后运行测试

pub run test -pdartium --pub-serve=8080

你能添加你的组件代码和你的主要方法吗。问题是关于Polymer 1.0的?这也是Firefox中的还是Dartium中的?我使用的是Polymer 1.0.0-rc.6。它发生在Linux上最新的Chrome上。代码在本报告中可用:我还建议在每个依赖项版本之前添加
^
,然后您将获得最新的可用版本,直至下一个“级别”。请看,我必须修改pubspec.yaml才能安装依赖项,因为您定义的版本并不都与我的Dart版本(1.14最新版本)兼容。对于生产来说,有严格的版本限制可能是有意义的。嗯,我确实用pub-serve运行了测试,但我认为我的端口不匹配。我会测试它当我到达它和报告回来。
pub run test -pdartium --pub-serve=8080