本文介绍了异常:NoSuchMethodError:未找到方法:'whenPolymerReady'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dart SDK 1.5.3 |聚合物0.11.0 + 5 Windows x64。当我创建一个使用模板'示例Web应用程序使用聚合物库(移动友好)选项'创建一个聚合物应用程序,并运行该应用程序它按预期工作,计数器递增时,该按钮被点击。

I am using Dart SDK 1.5.3 | polymer 0.11.0+5 | Windows x64. When I create a created a polymer application using the template 'Sample web application using the polymer library (mobile friendly) option' and run the application it works as expected with the counter incrementing when the button is clicked.

假设页面包含

<script type="application/dart">
  export 'package:polymer/init.dart';
</script>

是index.html,尝试通过从index.html中删除以下行来重构应用程序: p>

is index.html, attempting to refactor the application by removing the following lines from index.html

<click-counter count="5"></click-counter>
<link rel="import" href="clickcounter.html">

会导致以下错误:

Exception: NoSuchMethodError: method not found: 'whenPolymerReady'
Receiver: Instance of 'JsFunction'
Arguments: [Closure: () => dynamic] (package:polymer/src/loader.dart:115)
Breaking on exception: NoSuchMethodError: method not found: 'whenPolymerReady'

我在创建任何聚合物应用程序时一直使用这种机制,但从来没有看到这样的异常,虽然我看到的网络文档涉及Dart

I have used the mechanism all the time in creating any polymer app, but has never seen such exception although I have seen documentation on the web involving Dart https://www.google.com.jm/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CBwQFjAA&url=http%3A%2F%2Fcode.google.com%2Fp%2Fdart%2Fissues%2Fdetail%3Fid%3D19161&ei=MZq8U_nlK42KyASBkYHgCw&usg=AFQjCNHOc6MD-mhzPbDOmg8Hp5NeqVufqQ&bvm=bv.70138588,d.aWw

文档建议这个问题已解决,但它肯定存在于我使用的当前聚合物中。

The documentation suggested that this problem had resolved but it certainly is present in the current polymer I am using.

推荐答案

每个组件(每个文件包含< polymer-element> 标记)必须导入polymer.html。

Each of your components (each file containing a <polymer-element> tag) must import polymer.html.

确保您的clickcounter.html包含以下行:

Make sure your clickcounter.html contains the line:

<link rel="import" href="packages/polymer/polymer.html" />

(这是在0.11的突破变化)。

at the top. (It was breaking change in 0.11).

这篇关于异常:NoSuchMethodError:未找到方法:'whenPolymerReady'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:04