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

女爷i 2023-06-16 02:00 131阅读 0赞

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.

  1. export const verifyLogin = (isPushLogin: boolean = false) => {}
  2. // 改为
  3. export function verifyLogin(isPushLogin: boolean = false) {}
  4. /**
  5. * 验证登录
  6. * @param isPushLogin 未登录时,是否跳转登录
  7. */
  8. export function verifyLogin(isPushLogin: boolean = false) {
  9. return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
  10. const method = descriptor.value;
  11. descriptor.value = function() {
  12. if (this.appService && this.appService.isLogged() === false) {
  13. if (isPushLogin) {
  14. this.appService.askPushLogin();
  15. }
  16. return;
  17. }
  18. // 调用原始方法!!!
  19. return method.apply(this, arguments);
  20. };
  21. };
  22. }

发表评论

表情:
评论列表 (有 0 条评论,131人围观)

还没有评论,来说两句吧...

相关阅读