在Angular客户端上设置Cookie的方法如下:
npm install ngx-cookie-service
import { CookieService } from 'ngx-cookie-service';
constructor(private cookieService: CookieService) { }
this.cookieService.set('myCookie', 'cookieValue');
这将在客户端上设置一个名为"myCookie"的Cookie,其值为"cookieValue"。
this.cookieService.set('myCookie', 'cookieValue', 7, '/');
这将在客户端上设置一个过期时间为7天,路径为根路径的Cookie。
const myCookieValue = this.cookieService.get('myCookie');
这将返回名为"myCookie"的Cookie的值。
通过使用ngx-cookie-service库,您可以在Angular客户端上设置和获取Cookie,从而解决"Angular客户端上未设置Cookie"的问题。