将参数传递给匿名函数

时间:2016-03-05 00:35:41

标签: javascript function

我试图将一些indexeddb特定函数包装到一个对象。但它偶然发现了参数传递问题。

function DB_LINK_ROLE()
{
    this.general = new DB_LINK();
    this.cacheindex = new DB_LINK();
    this.locals = new Array();
    this.updatelist = new Array();
    this.checkwait = new WAIT_COUNTER();
}

DB_LINK_ROLE.prototype.init = function()
{
    this.checkwait.target++;
    this.general.req = indexedDB.open("gtn");
    this.general.req.onupgradeneeded = function () {
    // {...} other code
    this.general.state = 2; // Problem
    }
}

显然,函数内部的this对象包含事件特定数据。但我想访问DB_LINK_ROLE()对象属性。

这样做有什么办法吗?

0 个答案:

没有答案
相关问题