类型错误:“'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数或调用它们的参数对象上访问" [英] TypeError: "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"

查看:333
本文介绍了类型错误:“'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数或调用它们的参数对象上访问"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误"TypeError:在严格模式函数或调用它们的参数对象上可能无法访问'caller','callee'和'arguments'属性每当我尝试从我在我的承诺中的解决方案.这在好几天里工作得很好,现在突然它不起作用.我还尝试通过承诺中的分辨率传递相同的值.导致此错误的函数是:this.authenticateUser(registerForm.value);

I am getting this error " TypeError: "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them " Whenever I try to call a function from my resolution in my promise. This was working perfectly fine for multiple days and now all of a sudden it doesnt work. I also tried passing the same values through the resolution in the promise. The function that is causing this error is: this.authenticateUser(registerForm.value);

我尝试向函数参数字段添加不同的值不起作用.

I have tried adding different values to the function parameter field doesn't work. The

import { NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';

import { NotificationService } from '../notification/notification.service';
import { UserInterface } from 'src/app/models';

@Injectable({
  providedIn: 'root'
})
export class UserService {

  constructor(
    private httpClient: HttpClient,
    private router: Router,
    private notificationService: NotificationService,
  ) { }


  registerUser(registerForm: NgForm){
    console.log(registerForm.value)
      if( registerForm.value.email && registerForm.value.userName 
          && registerForm.value.firstName && registerForm.value.lastName 
          && registerForm.value.password && registerForm.value.confirmPassword
           ){

            if( registerForm.value.password === registerForm.value.confirmPassword ){

                this.httpClient.post(window.location.protocol + '//' + window.location.hostname + ':3000/register', registerForm.value)
                .toPromise()
                .then(
                  (res) => { 
                    this.authenticateUser(registerForm.value); 
                  }
                ) .catch((err) => { console.log(err); this.notificationService.addNotification(err); })

            } else { this.notificationService.addNotification('Password\'s Do Not Match'); }

      } else { this.notificationService.addNotification('Fill In All Fields'); }
  }

  loginUser(loginForm: NgForm) {
    if( loginForm.value.email && loginForm.value.password) {
      this.authenticateUser(loginForm.value);
    } else {
      this.notificationService.addNotification("Fill In All Field\'s");
    }
  }

  authenticateUser(loginData) {
    console.log.arguments(loginData);
    this.httpClient.post(window.location.protocol + "//" + window.location.hostname + ":3000/login", loginData)
      .toPromise()
      .then(
        (res: UserInterface) => { 
          localStorage.setItem('token', res.token);
          this.notificationService.addNotification('Login Successful');
          this.router.navigate((['/dashboard'])); 
        }
      )
      .catch((err) => { this.notificationService.addNotification(err); console.log(err);})
  }

  isLoggedIn() {

  }

} ```

Just trying to run this function in the resolution of this promise.


推荐答案

存在错误或输入错误 console.log.arguments(loginData) 应该是 console.log(loginData)

There is an error or mistype console.log.arguments(loginData) which should be console.log(loginData)

错误是在严格模式下禁止 arguments 属性.而且 Typescript 总是编译为严格模式的 Javascript.

The error is saying arguments property is forbidden in strict mode. And Typescript always compiles to strict mode Javascript.

这篇关于类型错误:“'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数或调用它们的参数对象上访问"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆