如何在查询字符串上调用serializeArray

有什么方法可以在查询字符串上调用serializeArray()吗?

str = "utf8=%E2%9C%93&authenticity_token=tzI2FU1g7SA8kZ94Nk0ykZ4nL6Kbp%2Fq8dg5%2BdEinpTnifta%2BWEu3ZzFkc3p5rUfQTQfJI8Q%3D%3D&entity_type=non-npe&caction=ABCD&aa_center=1100+-+Cossasations&numbers=&pat_numbers="

我尝试了$ .param(str).serializeArray(),但它对我不起作用。是否有任何内置方法。

评论
云淡,风清
云淡,风清

在字符串上调用serializeArray没有用

也许您的意思是这样的?

const parms = new URLSearchParams("utf8=%E2%9C%93&authenticity_token=tzI2FU1g7SA8kZ94Nk0ykZ4nL6Kbp%2Fq8dg5%2BdEinpTnifta%2BWEu3ZzFkc3p5rUfQTQfJI8Q%3D%3D&entity_type=non-npe&caction=ABCD&aa_center=1100+-+Cossasations&numbers=&pat_numbers=")

// it is now an array of key/value
  
parms.forEach((value, key) => console.log(key,":",value || "empty"));
点赞
评论