How to convert array to string in vue

青灯夜游
Release: 2022-03-07 15:24:36
Original
35375 people have browsed it

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
Copy after login

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"]
Copy after login

(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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!