项目中QS.stringify()中数组传递的不同方式

项目中QS.stringify()中数组传递的不同方式

在研究其他人的项目中遇到了数组传递的另外几种方式,因为之前我接触到的传参方式基本都是接受啥传啥,类似于:

	name:小红,
	age:18,
	hobby:[eat,game,shopping]

但是这个项目传递的参数却是这样的:

	name:小红,
	age:18,
	hobby:eat,
	hobby:game,
	hobby:shopping,

查看相关设置和文章得知QS.stringfty()有相关设置:
image

在QS插件中总共有这些参数可设置:

arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma' | undefined;

这里扩展一下其他参数的作用:
indices:

hobby[0]:eat,
hobby[1]:game,
hobby[2]:shopping,

brackets:

hobby[]:eat,
hobby[]:game,
hobby[]:shopping,

repeat:

hobby:eat,
hobby:game,
hobby:shopping,

comma:

hobby:eat,game,shopping,
posted @ 2021-12-15 11:00  言之空  阅读(1141)  评论(0)    收藏  举报