1

有人可以解释如何将以下结构转换为 jQuery 插件 - 因为我在这里真的很挣扎。我主要迷失对象属性、方法——如何将它们转换为单个插件:

var objLit = {
    thisObj : null,
    propOne : 125,
    propTwo : 300,
    propThree : null,
    methodOne : function(o) {

        if (o.length > 0) {

            objLit.thisObj = o;

            objLit.propOne = o.width();
            objLit.propTwo = o.height();

            objLit.convert();

        }

    },
    convert : function() {
        objLit.thisObj.animate({ 'width' : (objLit.propOne + 20) + 'px', 'height' : (objLit.propTwo + 20) + 'px' }, 300, function() {

            var tout = setTimeout(function() {

                objLit.propOne = (objLit.propOne - 20);
                objLit.propTwo =  (objLit.propTwo - 20);

                objLit.methodTwo();

            }, 2000);

        });
    },
    methodTwo : function() {

        etc...

    }
};
$(function() {

    objLit.methodOne($('.object'));

});

上面只是对象文字的一个例子——哇,我们可以把它转换成 jQuery 插件吗?

4

0 回答 0