項目中QS.stringify()中數組傳遞的不同方式
在研究其他人的項目中遇到了數組傳遞的另外幾種方式,因為之前我接觸到的傳參方式基本都是接受啥傳啥,類似於:
name:小紅,
age:18,
hobby:[eat,game,shopping]
但是這個項目傳遞的參數卻是這樣的:
name:小紅,
age:18,
hobby:eat,
hobby:game,
hobby:shopping,
查看相關設置和文章得知QS.stringfty()有相關設置:
在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,