0
点赞
收藏
分享

微信扫一扫

js中拆分类似于“aaa-bbb-ccc”字符

成义随笔 2022-03-21 阅读 46

getString(obj, state){

var index=obj.lastIndexOf("\-");

if(state==0){

obj=obj.substring(0,index);

}else {

obj=obj.substring(index+1,obj.length);

}

return obj;

}

let str = “aaa-bbb-ccc”

let str1 = this.getCaption(str,0) //aaa

let str2 = item.name2 = this.getCaption(str,1) //bbb

let str3 = item.name2 = this.getCaption(str,2) //ccc

举报

相关推荐

0 条评论