parseInt把company_id转换成数字,判断数字>=0的才要,其他的扔掉
<script>
console.log("before:",old_data)
let company_list = old_data.filter(item=>parseInt(item.company_id)>=0)
console.log("after:",company_list)
</script>
分割字符串成 001658 -> 00-16-58 每两位分割字符串:12345->12-34-5
let formate_code = '001658'
if(formate_code){
let formate_len = formate_code.length;
let new_formate = formate_code.match(/\w{2}/g).join("-");
//如果是奇数个数,则会出现最后一个无法截取,这里截取最后的数字,拼接上之前截取的
if(formate_len%2!==0){
let end_string = formate_code.substring(formate_len-1,formate_len);
new_formate = new_formate+'-'+end_string;
}
console.log(new_formate)
}
去除前两个字符串
var value = '2022-12-11';
value = value.slice(2, value.length);
console.log(value);
//输出结果 : 22-12-11