javascript - 角度 6+ 中未定义的 Cookie 值
问题描述
我正在使用角度和节点 js。我使用“CookieService”包
token.service.ts 类
SetToken(token) {
this.cookieService.set('chat_token', token);
}
GetToken() {
this.cookieService.get('chat_token');
}
试图在我的streams.component.ts中使用令牌服务,但我在“GetToken”中未定义这是我的Streams.component.ts
ngOnInit() {
this.token = this.tokenService.GetToken();
console.log(this.token);
}
请帮我解决这个问题。
解决方案
您只是忘记归还令牌
GetToken(): string {
return this.cookieService.get('chat_token');
}
推荐阅读
- html - 有一个包含 mapbox 地图宽度和高度属性根据设备屏幕大小调整大小
- com - 64 位托管进程:进程外 32 位 COM 服务器非默认接口不可用
- laravel - 无法调用组件方法。在组件上找不到公共方法 [previousPageUrl]
- ios - 在 SwiftUI 中的两个第一响应者文本字段之间切换时如何不关闭键盘
- oracle - Oracle 避免浪费性的加入回来?
- graphql - Hasura 在完成教程时崩溃了
- java - 尝试在 Jenkins 中保存工件配置时出错
- visual-studio-code - VS Code 不格式化包含嵌入式 HTML 的 PHP 脚本
- css - qss:选择除特定类型之外的所有小部件
- visual-studio-code - 如何使用 vscode api 显示大量信息?