Home  >  Article  >  Web Front-end  >  How to convert array to string in vue

How to convert array to string in vue

青灯夜游
青灯夜游Original
2022-03-07 15:24:3635427browse

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')".

How to convert array to string in vue

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 (,).

How to convert array to string in vue

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn