My code looks like this
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;
and I am calling it as follows
var Card = require('./Card.js');
var firstNode = this.rootNode.addChild(new Card());
but I am getting the following error
Uncaught TypeError: object is not a function
答案 0 :(得分:0)
确保为新的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;
module.exports = Card;