
cookie
蒲公英
前端小白晋级中……
展开
-
error:client:159 Cannot read property ‘0‘ of undefined
场景: 我在组件里使用CookieService,就报了这个错 import { CookieService } from 'ngx-cookie-service'; constructor( private cookieService: CookieService, ) {} 解决办法:在app.module.ts里引入CookieService import { CookieService } from 'ngx-cookie-service'; providers: [ .原创 2020-09-14 15:13:46 · 178 阅读 · 0 评论 -
给angular2项目添加cookies并在其他页面上获取
先说明下token的原理吧! 在浏览器端的结果是这样的: 登录成功的话,将token添加到cookie中,其他页面进行请求时,都要带上token值,来增加一层保护机制。好了,接下来讲具体实现吧! 1、安装 ngx-cookie-service 我用的是angular-cil,接下来的代码也是angular-cil的 npm install ngx-cookie-service --save...原创 2020-04-10 11:23:22 · 1463 阅读 · 0 评论