小编Ste*_*ven的帖子

在dojo Class中调用JavaScript的setTimeOut

我正在尝试将我的JavaScript函数转换为dojo类.我在我的setTimeOut("functionName",2000)一个JS方法中.如何使用dojo.declare方法从decared类中的方法调用它.例如,下面是我的自定义类.

    dojo.declare("Person",null,{
                    constructor:function(age,country,name,state){
                        this.age=age;
                        this.country=country;
                        this.name=name;
                        this.state=state;
                    },
                    moveToNewState:function(newState){
                        this.state=newState;
//I need to call "isStateChanged" method after 2000 ms. How do I do this?
                        setTimeOut("isStateChanged",2000);
                    },                  
                    isStateChanged:function(){
                        alert('state is updated');
                    }
                });
var person=new Person(12,"US","Test","TestState");
person.moveToNewState("NewState");
Run Code Online (Sandbox Code Playgroud)

请告诉我如何在2000ms之后isStateChangedmoveToNewState方法中调用方法.

javascript dojo settimeout

5
推荐指数
1
解决办法
9424
查看次数

标签 统计

dojo ×1

javascript ×1

settimeout ×1