当前位置:网站首页>JS截取字符串最后一个字符,截取“,”逗号前面字符,赋值集合
JS截取字符串最后一个字符,截取“,”逗号前面字符,赋值集合
2022-08-08 06:21:00 【ღ大美女的博客】
截取字符串最后一个字符
let str = '1600745882369.png,1600745882369.png,1600745882369.png,'
let strImg = str.substr(0, str.length - 1);
console.log(strImg); //1600745882369.png,1600745882369.png,1600745882369.png
截取“,”逗号前面字符,赋值集合中
let b_img = []
let listImg = []
var strVal = strImg.split(",");
for (var i = 0; i < strVal.length; i++) {
b_img = strVal[i]
const resData = {
img: b_img,
}
listImg.push(resData)
console.log(listImg);
}
// 打印结果[
// {
// "img": "1600745882369.png"
// },
// {
// "img": "1600745882369.png"
// },
// {
// "img": "1600745882369.png"
// }
// ]
判断是否object格式,服务器返回值 response
if(typeof response == ‘object’){}
集合对象转换
response = eval(‘(’ + response + ‘)’)
如果想学全栈开发,从写接口到,前端实现调接口,一整套流程,可以进群获取视频资料学习!
Java全栈交流①群要是满了可以加2群 1135453115, ②群 821596752
边栏推荐
猜你喜欢
随机推荐
分布式系统设计之高可用大全
chmod +x 的含义,为什么要chmod +x
screen 命令修改默认快捷键ctrl + a
状态压缩复习
字符串哈希 哈希值
Runtime - KVC, KVO principle
黑苹果安装
Completed - desktop interactive wizard design based on facial expressions (share the results, attach the data set of facial expressions and the yolov5 model trained by yourself and the interactive int
结合实践总结docker 安装 mysql5.7
四面拿下字节2-2Offer,入职就是...
pta补坑简单图论
NULL和nullptr的区别
基于Mysql的智慧医疗管理系统
string hash hash value
The tests that need to be done in the development of medical device products
The amount of parameters and calculation of neural network, is the neural network a parametric model?
cnn convolutional neural network backpropagation, convolutional neural network dimension change
Tensorboard 对训练性能影响
Why should Latches be avoided in digital IC design?
Docker安装nacos2.0并指定mysql,安装sentinel









