created() {
let webToken=this.getCookie(“webToken”) //填缓存在本地的cookies值
console.log(webToken)
},
getCookie(name) { //获取指定名称的cookie值
// (^| )name=([^;]*)(;|
)
,
m
a
t
c
h
[
0
]
为
与
整
个
正
则
表
达
式
匹
配
的
字
符
串
,
m
a
t
c
h
[
i
]
为
正
则
表
达
式
捕
获
数
组
;
v
a
r
a
r
r
=
d
o
c
u
m
e
n
t
.
c
o
o
k
i
e
.
m
a
t
c
h
(
n
e
w
R
e
g
E
x
p
(
"
(
∣
)
"
+
n
a
m
e
+
"
=
(
[
;
]
∗
)
(
;
∣
),match[0]为与整个正则表达式匹配的字符串,match[i]为正则表达式捕获数组; var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|
),match[0]为与整个正则表达式匹配的字符串,match[i]为正则表达式捕获数组;vararr=document.cookie.match(newRegExp("(∣)"+name+"=([;]∗)(;∣)"));
if(arr != null) {
// console.log(arr);
return unescape(arr[2]);
}
return null;
},
uni.app获取缓存在本地cookies的值
最新推荐文章于 2024-04-25 16:44:19 发布