RN:遇到一个字符串解构中的坑(安卓Release安装包中才出现)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/iOSTianNan/article/details/89644129

首先, 字符串可以看做一个 类似数组 的对象,
也可以通过解构的方式获取每个字符串


const [a,b,c,d,e] ="Hello";
console.log(a);   //H
console.log(b);   //e
console.log(c);   //l
console.log(d);   //l
console.log(e);   //o

出现的问题

let numString = "999";
[this.num1,this.num2,this.num3] = numString;

这行代码, 在iOS的debug模式/Release模式测试均ok
在android的debug模式测试也是ok,
不会出现中断程序的情况,

###唯独在android的Release包中,出现异常

解决方案:修改获取值的方式

this.num1 = numString.charAt(0);
this.num1 = numString.charAt(1);
this.num1 = numString.charAt(2);

猜你喜欢

转载自blog.csdn.net/iOSTianNan/article/details/89644129
今日推荐