Uncaught TypeError: object is not a function when inheriting from Node using Famous-Engine
Uncaught TypeError: object is not a function when inheriting from Node using Famous-Engine
我的代码是这样的
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Transitionable = require('famous/transitions/Transitionable');
var Node = require('famous/core/Node');
function Card() {
Node.call(this);
this.setAbsoluteSize(250, 250);
this.setSizeMode('absolute', 'absolute');
this.setPosition(FIRST_X_POSITION, Y_POSITION);
this.nodeDomElement = new DOMElement(this);
this.nodeDomElement.setProperty('backgroundImage', 'url(images/tile-03.png)');
this.nodeDomElement.setProperty('background-color', '#9a105f');
}
Card.prototype = Object.create(Node.prototype);
Card.prototype.constructor = Card;
我这样称呼它
var Card = require('./Card.js');
var firstNode = this.rootNode.addChild(new Card());
但我收到以下错误
Uncaught TypeError: object is not a function
确保为新 Card
class.
设置导出
module.exports = Card;
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Transitionable = require('famous/transitions/Transitionable');
var Node = require('famous/core/Node');
function Card() {
Node.call(this);
this.setAbsoluteSize(250, 250);
this.setSizeMode('absolute', 'absolute');
this.setPosition(FIRST_X_POSITION, Y_POSITION);
this.nodeDomElement = new DOMElement(this);
this.nodeDomElement.setProperty('backgroundImage', 'url(images/tile-03.png)');
this.nodeDomElement.setProperty('background-color', '#9a105f');
}
Card.prototype = Object.create(Node.prototype);
Card.prototype.constructor = Card;
module.exports = Card;
我的代码是这样的
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Transitionable = require('famous/transitions/Transitionable');
var Node = require('famous/core/Node');
function Card() {
Node.call(this);
this.setAbsoluteSize(250, 250);
this.setSizeMode('absolute', 'absolute');
this.setPosition(FIRST_X_POSITION, Y_POSITION);
this.nodeDomElement = new DOMElement(this);
this.nodeDomElement.setProperty('backgroundImage', 'url(images/tile-03.png)');
this.nodeDomElement.setProperty('background-color', '#9a105f');
}
Card.prototype = Object.create(Node.prototype);
Card.prototype.constructor = Card;
我这样称呼它
var Card = require('./Card.js');
var firstNode = this.rootNode.addChild(new Card());
但我收到以下错误
Uncaught TypeError: object is not a function
确保为新 Card
class.
module.exports = Card;
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Transitionable = require('famous/transitions/Transitionable');
var Node = require('famous/core/Node');
function Card() {
Node.call(this);
this.setAbsoluteSize(250, 250);
this.setSizeMode('absolute', 'absolute');
this.setPosition(FIRST_X_POSITION, Y_POSITION);
this.nodeDomElement = new DOMElement(this);
this.nodeDomElement.setProperty('backgroundImage', 'url(images/tile-03.png)');
this.nodeDomElement.setProperty('background-color', '#9a105f');
}
Card.prototype = Object.create(Node.prototype);
Card.prototype.constructor = Card;
module.exports = Card;