如何用(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个回答



您的代码也可以在没有以下代码的情况下工作,因为 blacklist </ code>未在 updateRecord()中使用 </ code>:</ p>

  const blackList = {}; 
formData.forEach(function(value,key){
blackList [key] = value;
} );
</ code> </ pre>
</ div>

展开原文

原文

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;
     });

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐