简体   繁体   English

我想将数组值存储在隐藏的输入字段中

[英]I want to store an array values in a hidden input field

const arr = [];
document.querySelector("#lengthParams").setAttribute('value',arr); 
<input type="hidden" id="lengthParams" name="lengthParams" value="">

the array is not null -> (3) ["0.00", "15.00", "15.00"] phpstorm suggests "Argument type any[] is not assignable to parameter type string".该数组不是 null -> (3) ["0.00", "15.00", "15.00"] phpstorm 建议“参数类型 any[] 不可分配给参数类型字符串”。 can anyone please suggest what changes should I make?谁能建议我应该做哪些改变?

let arr=['12','34','45']
arr=arr.toString()
document.querySelector("#lengthParams").setAttribute('value',arr);

You can make use of this你可以利用这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM