douwei1944 2019-05-21 13:07
浏览 116

如何用(Axios,php和vue.js)填充编辑表单中的当前数据

I'm new in (Axios, PHP, and vue.js), I want to populate the current data in the edit form the form without using the for loop

when I use the code below it does submit the data to the SQL database that I type in the inputs filed

   updateRecord: function (id) {
       let formData = new FormData();
       console.log(formData);
       formData.append('name', this.name);
        formData.append('msisdn', this.msisdn);

       const blackList = {};
         formData.forEach(function(value, key){
          blackList[key] = value;
         });
      axios({
         url: 'http://whizzdev/blackListEdit.php?id=' + id + "&action=update",
          method: 'post',
          data: formData,
          config: {headers: {'Content-Type': 'multipart/form-data'}}
        });
  <div class="modal-container">
         <form>
            <label>Name</label>
              <select v-model="name" type="select">
                <option>Prevent MSISDNS from PLAYING</option>
                <option>Prevent MSISDNS from WINNING</option>
              </select>
              <label>Msisdn</label>
              <input type="text" v-model="msisdn">
           </form>
            <button type="submit" value="update" @click="updateRecord(blackList.id)">Save</button>
            <button type="reset" @click="showModal = false">back</button>
          </div>
      </div>

</div>
  • 写回答

1条回答

  • doulei3488 2019-05-21 13:45
    关注

    Your code should also work without the following code as blacklist is not used inside updateRecord():

       const blackList = {};
         formData.forEach(function(value, key){
          blackList[key] = value;
         });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀