【问题标题】:Meteor Spiderable, errorsMeteor Spiderable,错误
【发布时间】:2015-01-05 10:36:04
【问题描述】:

当我测试 ?_escaped_fragment_= 时,我得到了

TypeError: 'undefined' is not a function (evaluating 'document.querySelectorAll.bind(document)')

http://localhost:3000/packages/material-design.js?e252ae03c7066a6ce33a348a22662a73cee8811e:75
http://localhost:3000/packages/material-design.js?e252ae03c7066a6ce33a348a22662a73cee8811e:315
http://localhost:3000/packages/material-design.js?e252ae03c7066a6ce33a348a22662a73cee8811e:318
http://localhost:3000/packages/material-design.js?e252ae03c7066a6ce33a348a22662a73cee8811e:778

正文中的 html 确实显示了,但我没有得到任何元标记,并且标题前的头部有一个巨大的空白。

我关注http://www.meteorpedia.com/read/spiderable/ 并运行了 phantomjs phantomtest.js

❯ phantomjs phantomtest.js [17:50:01] 正在加载页面... 页面加载状态:成功 还没准备好,流星未定义

我知道了。

知道有什么问题吗?谢谢。

【问题讨论】:

    标签: meteor


    【解决方案1】:

    spiderable 使用的phantomjs 中,不支持bind 方法。如果您是material-design 的所有者,我建议将bind 替换为_.bind。否则,您可以将a polyfill 添加到您的项目中,以确保正确定义Function.prototype.bind

    编辑

    为确保您的浏览器支持bind,请将此代码放在您的代码库中的某个位置:

    if (!Function.prototype.bind) {
      Function.prototype.bind = function(oThis) {
        if (typeof this !== 'function') {
          // closest thing possible to the ECMAScript 5
          // internal IsCallable function
          throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
        }
    
        var aArgs   = Array.prototype.slice.call(arguments, 1),
            fToBind = this,
            fNOP    = function() {},
            fBound  = function() {
              return fToBind.apply(this instanceof fNOP && oThis
                     ? this
                     : oThis,
                     aArgs.concat(Array.prototype.slice.call(arguments)));
            };
    
        fNOP.prototype = this.prototype;
        fBound.prototype = new fNOP();
    
        return fBound;
      };
    }
    

    上面的实现是从here复制/粘贴的。

    【讨论】:

    • 感谢您的回复。我是 web 开发的新手,你能详细介绍一下如何做 polyfill 吗?
    • 感谢您的回复。我添加了代码,但它仍然给我同样的错误。 Material-design 是我下载的一个流星包,是否有可能在调用此代码之前加载?有什么办法可以解决吗?非常感谢您的宝贵时间
    • 实际上材料设计是我项目中的一个包,所以我不明白为什么 polyfill 不能解决这个问题......
    • 您的“polyfill”应该修复它,但如果包中的这段特定代码在您的项目之前执行,那么您无能为力。我建议在包维护者的页面上报告问题。
    • 终于让它工作了,你的方法有效,我只需要在包之前运行 polyfill。非常感谢你。真的很感激。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-23
    • 1970-01-01
    • 2016-12-20
    • 2014-10-03
    相关资源
    最近更新 更多