Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中的方法链接_Javascript_Node.js_Sproutcore - Fatal编程技术网

javascript中的方法链接

javascript中的方法链接,javascript,node.js,sproutcore,Javascript,Node.js,Sproutcore,此工作代码正在使用Sproutcore: person = SC.Object.create({ firstName: 'Foo', lastName: 'Bar', fullName: function() { return this.get('firstName') + " " + this.get('lastName'); }.property() }); console.log(person.get('fullName')); // "

此工作代码正在使用Sproutcore:

person = SC.Object.create({
    firstName: 'Foo',
    lastName: 'Bar',
    fullName: function() {
        return this.get('firstName') + " " + this.get('lastName');
    }.property()

});

console.log(person.get('fullName')); // "Foo Bar"
我想知道property()是在哪里声明的,他们是如何实现的。 当我尝试在不使用SC类的情况下重建时,它给了我:

TypeError: Object function () {
        return this.get('firstName') + " " + this.get('lastName');
    } has no method 'property'

代码是如何工作的?

Sproutcore正在扩展函数原型

Function.prototype.property = function() { /* code here */ };
sproutcore使用的特定代码位于


在他们的例子中,他们使用自己的mixin方法,但概念是相同的:扩展原型

据推测,Sproutcode修改了
函数。原型
包含
属性
函数


你可以看看。

是的,我是编程新手。我怎么知道这个代码在哪里?@weng:,或者看看SproutCore网站(也可以通过谷歌找到)@weng:哦!很抱歉这就是github搜索的目的。不幸的是,它现在似乎在下降:
SC.mixin(Function.prototype, 
//...snip...

property: function() {
    this.dependentKeys = SC.$A(arguments) ;
    var guid = SC.guidFor(this) ;
    this.cacheKey = "__cache__" + guid ;
    this.lastSetValueKey = "__lastValue__" + guid ;
    this.isProperty = YES ;
    return this ;
  },
//snip
);