class Button { @ BuridDecorator @ LoginDecorator click ( ) { console . log ( '点击 dom' ) ; } } function LoginDecorator ( target , name , descriptor ) { const oriFun = target [ name ] ; descriptor . value = async function ( ) { const code = await Login ( ) ; if ( code === 0 ) { console . log ( '登陆成功' ) ; oriFun . call ( this , ... arguments ) ; } } ; } function BuridDecorator ( target , name , descriptor ) { console . log ( `${ name } 方法添加了一个埋点` ) ; } async function Login ( ) { return new Promise ( ( resolve , reject ) => { setTimeout ( ( ) => { resolve ( 0 ) ; } , 1000 ) ; } ) ; } const btn = new Button ( ) ; btn . click ( ) ;