我需要在流星上使用幻像。如果我使用单独的脚本,一切正常。如果我正在使用流星,我会收到错误。
import React, { Component } from 'react';
var phantom = require('phantom');
phantom.create().then(function(ph) {
ph.createPage().then(function(page) {
page.open('https://stackoverflow.com/').then(function(status) {
console.log(status);
page.property('content').then(function(content) {
console.log(content);
page.close();
ph.exit();
});
});
});
});
export default class App extends Component {
render() {
return (
<div className="container"></div>
);
}
}
C:\OpenServer\domains\EM-topface-like\node_modules\phantom\lib\phantom.js:53 function createLogger({ logLevel = defaultLogLevel } = {}) { SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\OpenServer\domains\EM-topface-like\node_modules\phantom\lib\index.js:7:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10) Exited with code: 1 Your application is crashing. Waiting for file change.
如何解决?