我正在关注此angular2-authentication-sample进行身份验证。我不希望客户端jwt_dcode和jwt_encode在项目中删除了两者。但我仍然在此文件home.ts
(24,42): error TS2339: Property 'jwt_decode' does not exist on type 'Window'.
import { Component } from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
import { Router } from '@angular/router';
const styles = require('./home.css');
const template = require('./home.html');
@Component({
selector: 'home',
directives: [ CORE_DIRECTIVES ],
template: template,
styles: [ styles ]
})
export class Home { }
答案 0 :(得分:2)
我遇到了同样的问题,最后使用了JwtHelper类。
导入:
Handlers.routing(false)
实例化:
import { AuthHttp, JwtHelper } from 'angular2-jwt';
使用:
jwtHelper: JwtHelper = new JwtHelper();