(24,42):错误TS2339:类型'Window'上不存在属性'jwt_decode'

时间:2016-10-04 14:50:08

标签: angular typescript

我正在关注此angular2-authentication-sample进行身份验证。我不希望客户端jwt_dcode和jwt_encode在项目中删除了两者。但我仍然在此文件home.ts (24,42): error TS2339: Property 'jwt_decode' does not exist on type 'Window'.

中收到错误

home.ts

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 { }

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,最后使用了JwtHelper类。

导入:

Handlers.routing(false)

实例化:

import { AuthHttp, JwtHelper } from 'angular2-jwt';

使用:

jwtHelper: JwtHelper = new JwtHelper();