天天看点

截去字符串的第一个和最后一个字符

newObj:[{astr:'[123,456]'},{astr:'fadsfsdc'},{astr:'[123,456]'},{astr:'[123,456]'}]
spliceStr(){
     newObj.map((item)=>{
        if( item.astr[0]==='['){
          item.astr=item.astr.substring(1,item.astr.length-1)
        }
      })
      console.log(newObj)
    },
           
截去字符串的第一个和最后一个字符
js