Add dynamic key, value pairs to JavaScript array or hash table

前端 未结 5 1626
醉话见心
醉话见心 2020-12-12 19:51

I\'m trying to add a key value pair to an existing javascript associative array. The key needs to be a variable. This is for JSON encoding. I realize there are many plugins

5条回答
  •  盖世英雄少女心
    2020-12-12 20:18

    const tStyles = [];
    for (const i of iStyles) {
      const temp = {};
      temp[`${style}`] = `../dist/css/uikit.${wFile}.${style}.css`;
      tStyles.push(temp);
    }
    

    json : {"black-beige":"../dist/css/uikit.or.black-beige.css"}

提交回复
热议问题