【问题标题】:Getting dynamic field data using vue.js in laravel在 laravel 中使用 vue.js 获取动态字段数据
【发布时间】:2020-11-30 19:56:01
【问题描述】:

我正在创建多个动态字段,并将相同的内容发布到 laravel 控制器方法,但我能够获取简单字段数据(非动态生成的字段),但动态生成的数组字段我'我无法进入控制器方法。

 <input :name="'students['+studentdetails.id+']['+studentdetails.class+']'" type="text" class="form-control"/>
 <input :name="'students['+studentdetails.id+']['+studentdetails.class+']'" type="text" class="form-control"/>

当我得到它时,在我的控制器方法中:

  printr($request->attributes);


 export default {
  data() {
...

return {
      
      form: new Form({
        title: "",
        attributes: [],
        }),
   };

  addStudent() {
          const header = {
            Authorization: "Bearer " + this.token,
          };
          this.form
            .post(APP_URL + `/api/addStudent`, { headers: header })
            .then((response) => {
              if (response.status == 200) {
                location.replace(APP_URL + "/success");
              } 
            });
        },
};

没有价值。

【问题讨论】:

    标签: laravel vue.js laravel-5 vuejs2


    【解决方案1】:

    您现在将[]students 创建为字符串,它们不应该是。完全删除字符串引号,因为您只使用变量:

    :name="students[studentdetails.id][studentdetails.class]"
    

    【讨论】:

      猜你喜欢
      • 2021-12-15
      • 1970-01-01
      • 2019-05-08
      • 2020-01-21
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多