This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!

Some small projects, no need to build scaffolding, directly in the way of CDN introduction

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" SRC = "https://cdn.bootcss.com/qs/6.7.0/qs.min.js" > < / script > < script type = "text/javascript" SRC = "https://cdn.bootcss.com/axios/0.18.0/axios.min.js" > < / script > < / head > < body > < div > < / div > < script Type ="text/javascript"> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> =" window.qs "> Var qs.stringify() var qs.stringify() Qs. Stringify (var) Qs = Qs / / configuration of the post request header axios. Defaults. Headers. Post = [' the content-type '] 'application/x-www-form-urlencoded' // qs.stringify() axios.post('url', qs.stringify() {id: 1, name: 'LXW'}).then(function (res) {// Promise object data}) </script> </body> </ HTML >Copy the code

Some ways to use QS

Qs. Parse method can convert a formatted string to object format, such as let url = 'http://localhost/index.htm? a=1&b=2&c=&d=xxx&e'; let data = qs.parse(url.split('? ') [1]); // data results in {a: 1, b: 2, c: ", d: XXX, e: "} qs.stringify The basic use of qs.stringify, as opposed to qs.parse, formats a parameter object into a string. let params = { c: 'b', a: 'd' }; Qs.stringify (params) // The result is 'c=b&a=d' sort and can even sort formatted arguments: Qs.stringify (params, (a,b) => a.localecompare (b)) // The result is 'a=b&c=d'; let params = [1, 2, 3]; // indices(default) qs.stringify({a: params}, {arrayFormat: 'indices'}) / / as a result,' a [0] = 1 & a [1] = 2 & a [2] = 3 '/ / brackets qs stringify ({a: params}, {arrayFormat: 'brackets'}) / / as a result,' a [] = 1 & 2 & a [] a [] = = 3 '/ / repeat qs stringify ({a: params}, {arrayFormat: }) let json = {a: {b: {c: 'd', e: 'f'}}}; let json = {b: {c: 'd', e: 'f'}}; qs.stringify(json); // result 'a[b][c]=d&a[b][e]=f' / / result 'A.B.C = d&a. B.e = f'Copy the code