【问题标题】:go to a laravel controller using vue js's data使用 vue js 的数据转到 laravel 控制器
【发布时间】:2023-03-14 16:00:01
【问题描述】:

这是我的vue

new Vue({
              el: '#notificationMenu',
              data: {
                showModal: false,
                patients: [],
                duepatients: []
              },
                created: function(){
                    this.getPatients();
                    this.addUsers();
                },
                methods: {
                    getPatients: function(){
                           $.getJSON("{{route('api_patients')}}", function(patients){
                            this.patients = patients;
                        }.bind(this));
                        setTimeout(this.getPatients, 1000); 
                    },
                    addUsers: function(){
                      this.$http.get('/govaccine/addUsers', '').then((response) => {

                      }, (response) => {
                        this.formErrors = response.data;
                        });

                       setTimeout(this.addUsers, 10000);                          
                    },sendSMS: function(val){

                      $.getJSON('sendsms/' + val,function(duepatient){
                            this.duepatients = duepatient;
                      }.bind(this));

                    }
                }

            });

这是我的html

<ul class="notifications-list" v-for="patient in patients">
                        <li class="item no-data">You don't have notifications</li>

                                <!-- use the modal component, pass in the prop -->
                          <modal v-if="showModal" @close="showModal = false">
                            <!--
                              you can use custom content here to overwrite
                              default content
                            -->
                            <h3 slot="header">custom header</h3>
                          </modal>
                            <a v-on:click="sendSMS(patient.due_date)">
                                <li class="item js-item " data-id="5" >
                                    <div class="details">
                                        <strong>@{{ patient.total}} patients</strong> are due for immunization on @{{patient.due_date}}
                                        <span class="date">{{--  @{{patient.created_at}} --}}</span>

                                    </div>
                                    <button type="button" class="button-default button-dismiss js-dismiss">×</button>
                                </li>
                            </a>
                    </ul> 

如果我使用 v-for 循环遍历 vue js 数据,我如何在 {{route('patient.show', parameter)}} 中的每个循环中传递数据,以便我可以在其上放置一个参数。

还是有什么办法可以转到控制器并转到其他页面?

【问题讨论】:

    标签: laravel routes vue.js


    【解决方案1】:

    是的,您应该使用路由器链接。完整示例here。 如果我把你的问题弄错了,请告诉我。

    【讨论】:

      猜你喜欢
      • 2019-10-18
      • 1970-01-01
      • 2019-10-19
      • 2019-07-07
      • 2023-04-03
      • 2021-11-04
      • 2020-09-01
      • 2017-07-07
      • 2020-05-24
      相关资源
      最近更新 更多