前台后台数组类型转换(字符串转数组,数组转字符串,去掉引号)
前台数组转成字符串存储;
this.materials=[];
let permission = this.materials.join(",");
前台展示需要获取出来值,转成数组后,会带引号:
例:
["1","2","3"]
前台应用时候,例如给el-select 赋值多选时,需要去掉引号才可以:
先转成数组
["1","2","3"]
再处理引号:
this.materials=this.form.material.split(',')
this.materials=this.materials.map(Number)
其他类型转换:
引自https://www.cnblogs.com/xx321/p/14959997.html