gpt4 book ai didi

javascript - paper-header-panel - 手动将处理程序分配给事件内容滚动

转载 作者:行者123 更新时间:2023-11-30 12:17:08 25 4
gpt4 key购买 nike

使用 polymer 1.1,我不想为 paper-header-panel 制作自定义元素或模板。如何在滚动事件上分配处理程序?

我试过:

bob = Polymer.dom(document).querySelector('paper-header-panel');
bob.scrollHandler = function() {
console.log('ssssssss');
}

没有成功。

https://github.com/PolymerElements/paper-header-panel/blob/master/paper-header-panel.html#L186

来自文档

Polymer({
is: 'paper-header-panel',
/**
* Fired when the content has been scrolled. `event.detail.target` returns
* the scrollable element which you can use to access scroll info such as
* `scrollTop`.
*
* <paper-header-panel on-content-scroll="{{scrollHandler}}">
* ...
* </paper-header-panel>
*
*
* scrollHandler: function(event) {
* var scroller = event.detail.target;
* console.log(scroller.scrollTop);
* }
*
* @event content-scroll
*/

  ready: function() {
this.scrollHandler = this._scroll.bind(this);
this._addListener();

最佳答案

如果我没看错你的问题,你想像这样在js中订阅事件-

ready: function () {
this.$.panel.addEventListener("content-scroll", function () {
console.log('ssssssss');
});
}

但我没明白为什么你不能像文档中那样做。


bob = Polymer.dom(document).querySelector('paper-header-panel');
bob.addEventListener("content-scroll", function () {
console.log('ssssssss');
}

关于javascript - paper-header-panel - 手动将处理程序分配给事件内容滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32146968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com