在vue.js中不会触发click事件

时间:2018-10-06 10:10:51

标签: javascript vuejs2

在模式中,我想在单击按钮时运行方法 这是模式代码:

 <div class="modal fade" id="new" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
             aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLongTitle">@lang('admin.new')</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12 create text-center  font-rtl">
                            <div class="form-group form-md-line-input  col-xs-12  text-center">
                                <label for="form_control_1">@lang('admin.type')</label>
                                <input type="text" class="form-control" name="type" id="form_control_1"
                                        required v-model="da.type">
                            </div>
                            <div class="form-group form-md-line-input col-xs-12 ">
                                <label for="form_control_1">@lang('admin.status')</label>
                                <select class="form-control" name="active"  required v-model="da.active">
                                    <option value=""></option>
                                    <option value="true">@lang('admin.active')</option>
                                    <option value="false">@lang('admin.inactive')</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button class="btn btn-primary bb" @click="post_type()">@lang('admin.save')</button>
                    </div>
                </div>
            </div>
        </div>

并且我的方法是在外部.ts文件中定义的:

post_type() {
            post_data(this.da).subscribe(function (x: any) {

                if (x.status == "failure") {
                    // toastr[]("Gnome & Growl type non-blocking notifications", "Toastr Notifications")

                    toastr.error(x.message);
                } else {
                    // console.log(result.status);
                    // location = "/admin/category?type_id="+this.type_id;
                    this.get_type_data();
                    $('#new').modal('toggle');
                    this.da.type = '';
                    this.da.active = '';
                    toastr.success(x.message);
                }

            });


        },

我在其他页面上执行此操作,但它可以正常工作,但对于这一页不起作用,甚至无法触发。 我该怎么办?

0 个答案:

没有答案