我尝试将hammer:hammer 2.0.4_2 包与 Meteor 1.0.1 一起使用,但收到以下错误:
Exception from Tracker afterFlush function: undefined is not a function TypeError: undefined is not a function
我认为该错误与 DOM 尚未渲染有关,因为 Helper Block 的原因。到目前为止我在任何地方都找不到这个问题的答案。其他人是否有同样的错误或知道如何解决此问题?
<小时/>client/profile.js
Template.myTemplate.rendered = function() {
this.$('body').hammer({ <-- Line of the Error in Console..
drag_min_distance:1,
swipe_velocity:0.1
})
}
Template.myTemplate.events({
'press #mcPress': function() {
console.log('yay!')
}
})
<小时/>
client/profile.html
{{#with thisUser}}
// some html stuff
<div id="mcPress">Some content</div>
{{/with}}
<小时/>
最佳答案
Hammer.js 作为独立版本(这是官方包的提供方式)不随 jQuery plugin 一起提供,因此如果您不自己手动添加 jQuery 插件,则无法使用该语法。
你可以很容易地对该包进行本地 fork 并安装插件(我还没有发布这个,因为我对 Atmosphere 命名空间困惑问题非常敏感)。或者,您可以只在页面加载时包含该插件。不管怎样,该语法应该有效,否则,您只需使用 core docs 中描述的非 jQuery 语法。 .
关于javascript - Meteor 和 Hammer JS 包的跟踪器 afterFlush 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27517253/