修饰器

function arrest(target, calleeName, descriptor) {
        let oriFunc = descriptor.value;
        descriptor.value = function(...args){
            return Promise.resolve(oriFunc.apply(this, args))
                .then(res =>{
                    return Promise.resolve([null, res]);
                })
                .catch(err => {
                    return [err, null];
                });
        };
    };

@arrest()
async postFormId({habitID, type, formId}) {
    return await wx.$api.util.postFormId({habitID, type, formId});
},

  

posted @ 2019-01-31 10:18  霜末之冬  阅读(120)  评论(0编辑  收藏  举报