1

在 Meteor.js 中使用 Phantom.js 和phantomNPM 包时,我收到一条错误消息,指出Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

我尝试findOneMeteor.wrapAsyncPhantom 的回调函数包装函数,Meteor.bindEnvironment但错误仍然存​​在。

我们能做什么?

var phantom = Meteor.npmRequire('phantom')
phantom.create(Meteor.bindEnvironment( function (ph) {
  ph.createPage(function (page) {
    page.open('http://www.google.com', function (status) {

        console.log('Page Loaded');

        page.evaluate( function () { 
            return document.documentElement.outerHTML; 
        }, function (html) {

            // ERROR OCCURS HERE
            Animals.findOneAsync = Meteor.wrapAsync(Animals.findOne)
            var animals = Animals.findOneAsync({city:'boston'})

        });

        ph.exit();

    });
  });
}) );

错误:

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
4

0 回答 0