在 Dart 中为聚合物中的事件添加事件侦听器
Add event listener in Dart for events in polymer
需要为 core-header-transform 添加事件侦听器,来自 dart 包中的 core-scroll-header-panel 元素 core_elements。我该怎么做?
app.html:
<template>
<core-scroll-header-panel id="scroll-panel" condenses flex>
<core-toolbar class="tall">
<header id="main-header" horizontal layout flex>
<div id="application-name">
status
<server-status></server-status>
</div>
</header>
<div class="bottom indent title">title</div>
</core-toolbar> </template>
飞镖app.dart:
import 'package:polymer/polymer.dart';
@CustomTag('some-app')
class SomeApp extends PolymerElement {
Some.created() : super.created();
onReady(){
var coreScrollHeader = $['scroll-panel'];
coreScrollHeader.on['core-header-transform'].listen((event){
print('core-header-transform');
});
}
}
在pubspec.yaml中:聚合物:“^0.16.3+3”
首先确保 Polymer 已正确初始化(有关详细信息,请参阅 how to implement a main function in polymer apps)
像这样注册事件侦听器:
@whenPolymerReady
onReady(){
var coreScrollHeader = querySelector('* /deep/ #scroll-panel');
coreScrollHeader.on['core-header-transform'].listen((event){
print('core-header-transform');
});
}
需要为 core-header-transform 添加事件侦听器,来自 dart 包中的 core-scroll-header-panel 元素 core_elements。我该怎么做?
app.html:
<template>
<core-scroll-header-panel id="scroll-panel" condenses flex>
<core-toolbar class="tall">
<header id="main-header" horizontal layout flex>
<div id="application-name">
status
<server-status></server-status>
</div>
</header>
<div class="bottom indent title">title</div>
</core-toolbar> </template>
飞镖app.dart:
import 'package:polymer/polymer.dart';
@CustomTag('some-app')
class SomeApp extends PolymerElement {
Some.created() : super.created();
onReady(){
var coreScrollHeader = $['scroll-panel'];
coreScrollHeader.on['core-header-transform'].listen((event){
print('core-header-transform');
});
}
}
在pubspec.yaml中:聚合物:“^0.16.3+3”
首先确保 Polymer 已正确初始化(有关详细信息,请参阅 how to implement a main function in polymer apps)
像这样注册事件侦听器:
@whenPolymerReady
onReady(){
var coreScrollHeader = querySelector('* /deep/ #scroll-panel');
coreScrollHeader.on['core-header-transform'].listen((event){
print('core-header-transform');
});
}