本文章为个人学习记录,如有错误多多指定。
一、截取指定字符串
export default {
data() {
return {
imgArr: ['blob:http://8.141.77.156/uploads/app/20210708/5f966bf743ac65fd87f93fd627753ae0',
'blob:http://8.141.77.156/uploads/app/20210708/5f966bf743ac65fd87f93fd627753ae0',
'blob:http://8.141.77.156/uploads/app/20210708/5f966bf743ac65fd87f93fd627753ae0'],
imgList:[],
}
},
created() {
for( let i=0;i<this.imgArr.length;i++){
this.imgList.push(this.imgArr[i].slice(5,this.imgArr[i].length)+ '.jpg')
}
console.log(this.imgList)
},
}
输出:
二、删除指定字符
export default {
data() {
return {
imgList:['http:/\/8.141.77.156\/uploads\/app\/20210709\/05279233e4408e724d7ec653859e2d31.jpg',
'http:/\/8.141.77.156\/uploads\/app\/20210709\/05279233e4408e724d7ec653859e2d31.jpg',
'http:/\/8.141.77.156\/uploads\/app\/20210709\/05279233e4408e724d7ec653859e2d31.jpg'],
arr:[]
}
},
created() {
for(let i=0;i<this.imgList.length;i++){
let str=new RegExp(" \ ")
this.arr.push(this.imgList[i].replace(str,''))
}
console.log(this.arr)
},
}
输出:
三、删除双反斜杠
export default {
data() {
return {
imgList:['[\"http:\\/\\/8.141.77.156\\/uploads\\/app\\/20210709\\/4a237e28994655ca85bc6cfe7c0f6037.jpg\"]',
'[\"http:\\/\\/8.141.77.156\\/uploads\\/app\\/20210709\\/4a237e28994655ca85bc6cfe7c0f6037.jpg\"]',
'[\"http:\\/\\/8.141.77.156\\/uploads\\/app\\/20210709\\/4a237e28994655ca85bc6cfe7c0f6037.jpg\"]'],
list: []
}
},
created() {
for (let i = 0; i < this.imgList.length; i++) {
this.list.push(this.imgList[i].slice(2,this.imgList[i].length-2).replace(/[\\]/g,''))
}
console.log(this.list)
},
}
输出: