Bij*_*wat 0 javascript android ios react-native
在React Native中如何将String转换为数组 例如:-
var myString = 'this, is my, string';
Run Code Online (Sandbox Code Playgroud)
带有","
和输出的单独字符串必须是
myArray = [this, is my, string];
on myArray[0] value is "this",
on myArray[1] value is " is my",
on myArray[2] value is " string"
Run Code Online (Sandbox Code Playgroud)
只需使用string.split()逗号作为分隔符,即可将字符串拆分为一个数组。
var myArray = myString.split(',');
Run Code Online (Sandbox Code Playgroud)
var myString = 'this, is my, string';
console.log(myString.split(','));Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6225 次 |
| 最近记录: |