In vue, you can use the join() method to convert the array into a string. This method can return the array as a string. The array elements will be separated using the specified delimiter; the syntax is "array object. join('separator')".
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
Vue: Conversion between strings and arrays
1. Array to string conversion
You can use the join() method to convert the array into a string.
join() method returns the array as a string. The elements will be separated by the specified delimiter. The default delimiter is comma (,
).
var authority= ['1','2']; let permission = authority.join(","); console.log(permission )//1,2
2. Convert string to array
split() is used to split a string into a string array.
var a='1,2' a.split(',') console.log(a)// ["1", "2"]
(Learning video sharing: vuejs tutorial, web front-end)
The above is the detailed content of How to convert array to string in vue. For more information, please follow other related articles on the PHP Chinese website!