baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.4k stars 2.52k forks source link

amis登录,将token保存到localStorage,跳转页面,CRUD怎样赋值localStorage? #11242

Open wanquantong opened 8 hours ago

wanquantong commented 8 hours ago

实现场景:(amis版本:6.9)

1.登录,将token保存到localStorage,token获取到了,跳转页面到首页,也跳转成功,

if (payload.token != "") {
  localStorage.setItem("token", payload.token);
  localStorage.setItem("xtoken", payload.xtoken);
  console.log(payload.token);
}

2.首页:CRUD增删改查表格,接口的请求头,赋值localStorage,没效果。 请问怎么实现?

"headers": {
      "token": "${localStorage.getItem('token')}"
    }
lhtuling commented 1 hour ago

用法不对,看官方文档

https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/data-mapping#namespace

Amis低代码前端框架交流群【QQ1群】:717791727 Amis低代码前端框架交流群【QQ2群】:721182449