Function expressions are not supported in decorators changing the function ... exported function.

ionic4 angular8 打包报错:

ERROR in src/app/pages/user/user.service.ts(30,28): Error during template compile of 'verifyLogin'
  Function expressions are not supported in decorators
    Consider changing the function expression into an exported function.

export const verifyLogin = (isPushLogin: boolean = false) => {}


// 改为

export function verifyLogin(isPushLogin: boolean = false) {}
/**
 * 验证登录
 * @param isPushLogin 未登录时,是否跳转登录
 */
export function verifyLogin(isPushLogin: boolean = false) {
    return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
        const method = descriptor.value;
        descriptor.value = function() {
            if (this.appService && this.appService.isLogged() === false) {
                if (isPushLogin) {
                    this.appService.askPushLogin();
                }
                return;
            }
            // 调用原始方法!!!
            return method.apply(this, arguments);
        };
    };
}
发布了79 篇原创文章 · 获赞 40 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/u013727805/article/details/103216687