两个父函数都被子进程覆盖.孩子中有两个叫父母的两个.但是,我期望在父级别,对一个人的调用会调用孩子的方法.有一个我缺少的概念吗?
先感谢您!
function parent(){}
parent.prototype.one = function(){
$('body').append("Parent: one <br/>");
}
parent.prototype.two = function(){
this.one();
$('body').append("Parent: two <br/>");
}
function child(){}
child.prototype = new parent();
child.prototype.constructor = child;
child.prototype.one = function(){ //should this function not be called?
$('body').append('Child: one <br />');
}
child.prototype.two = function(){
$('body').append('Child: do some child stuff here and call parent: <br />');
parent.prototype.two();
}
var k = new child();
k.two();
Run Code Online (Sandbox Code Playgroud) 在 Sequelize.js 中,我创建了一个示例迁移文件:
module.exports = {
up: function(migration, DataTypes, done) {
// add altering commands here, calling 'done' when finished
migration.createTable('Users', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
createdAt: {
type: DataTypes.DATE
},
updatedAt: {
type: DataTypes.DATE
},
firstname: DataTypes.STRING,
lastname: DataTypes.STRING,
email: DataTypes.STRING,
password: DataTypes.STRING,
});
done()
},
down: function(migration, DataTypes, done) {
// add reverting commands here, calling 'done' when finished
done()
}
}
Run Code Online (Sandbox Code Playgroud)
有人能解释一下 up 和 down 功能的用例和可能的实现吗?
谢谢!