" NoSuchCapabilityError:无法调用方法"为按钮分配动作时

时间:2016-06-27 16:01:11

标签: dart dart-polymer

main_app.html:

<dom-module id="main-app">
  *snip*
  <template>
    *snip*
      <paper-button on-tap="nextStep" raised>Next step</paper-button>
      <p>The step is {{step}}</p>
  </template>
</dom-module>

main_app.dart:

@HtmlImport('main_app.html')

*snip*

@PolymerRegister('main-app')
class MainApp extends PolymerElement {
  *snip*

  @property int step = 0;

  MainApp.created() : super.created();

  *snip*

  @reflectable
  void nextStep() {
      step = step + 1;
      print('Next step!');
  }
}

当我运行此按钮时,我在Dartium的控制台中收到此错误:

NoSuchCapabilityError: no capability to invoke the method 'nextStep'

我做错了什么?

1 个答案:

答案 0 :(得分:2)

请尝试

void nextStep(event, [_]) {

void nextStep([_, __]) {