【问题标题】:How to populate the current data in the edit form with (Axios, php and vue.js)如何使用(Axios、php 和 vue.js)在编辑表单中填充当前数据
【发布时间】:2019-10-07 21:22:13
【问题描述】:

我是(Axios、PHP 和 vue.js)的新手,我想在表单的编辑表单中填充当前数据,而不使用 for 循环

当我使用下面的代码时,它会将数据提交到我在输入字段中键入的 SQL 数据库

   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>

【问题讨论】:

    标签: php vue.js axios


    【解决方案1】:

    您的代码也应该在没有以下代码的情况下工作,因为blacklist 没有在updateRecord() 中使用:

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

    【讨论】:

      猜你喜欢
      • 2021-03-11
      • 1970-01-01
      • 2021-01-29
      • 2020-08-04
      • 2018-09-06
      • 1970-01-01
      • 2021-05-20
      • 2015-08-26
      • 2016-06-23
      相关资源
      最近更新 更多