Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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 此.set不是函数错误_Javascript_Ember.js - Fatal编程技术网

Javascript 此.set不是函数错误

Javascript 此.set不是函数错误,javascript,ember.js,Javascript,Ember.js,在我的控制器内,我有以下代码可以淡出div: popUpFadeOut: function(){ if(this.get('bid.popUpContainerOpacity') === 0){ this.set('bid.popUpContainerOpacity', 1); this.set('bid.popUpContainerDisplay', 'block'); setTimeout(this.fading, 1000); //popup box fades away after

在我的控制器内,我有以下代码可以淡出div:

popUpFadeOut: function(){
if(this.get('bid.popUpContainerOpacity') === 0){
this.set('bid.popUpContainerOpacity', 1);
this.set('bid.popUpContainerDisplay', 'block');   
setTimeout(this.fading, 1000); //popup box fades away after 1 seconds
}
},

fading: function() {
    this.set('bid.popUpContainerOpacity', 'bid.popUpContainerOpacity' - 0.1);

    if (this.get('bid.popUpContainerOpacity') <= 0)
    {
       this.set('bid.popUpContainerOpacity', 0);
       this.set('bid.popUpContainerDisplay', 'none');
    }
    else
    { 
       requestAnimationFrame(this.fading);
    }
},
虽然我不是'this'关键字的专家,但我猜它找不到该函数,因为在popUpFadeout中调用了淡入淡出,因此在淡入淡出中调用this.set将在popUpFadeout中查找不存在的set方法


我的问题是:如何访问控制器的set方法

在超时调用中,切换到
this.disking.bind(this)
。然后,您应该将调用set时要使用的适当的
this
绑定

try
setTimeout(this.facing.bind(this),1000)instead@DiogoSgrillo现在它说无法读取淡入淡出中未定义(…)的属性“set”。我将“.bind(this)”放在另一个this.facing上,现在它也可以工作了。谢谢
Uncaught TypeError: this.set is not a function(…)