Skip to content
Exodia edited this page Jun 12, 2016 · 3 revisions

uioc内置了aop插件,其基于uaop的函数拦截api,提供了够对组件方法进行横向拦截的功能。 uaop的相关术语以及api详见:uaop

在组件配置中通过aopConfig配置项进行aop的相关配置:

let config = {
    components: {
        list: {
            module: 'app/List',
            aopConfig: {
                advisors: [
                    {
                        matcher: /method/,
                        advices: {
                            before(...args) {},
                            afterReturning(returnValue) {},
                            afterThrowing(){},
                            after(){},
                            around(joinPoint){}
                        }
                    },
                    {
                        matcher: 'doSomething',
                        advices: {
                            before(...args) {}
                        }
                    },
                    {
                        matcher: (obj, propertyName) => propertyName.lastIndexOf('doSomething1') !== -1,
                        advices: fixtureAdvices
                    }
                ]
            }
        }
    }
};
Clone this wiki locally