添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currently using v-on:ok like so:

<b-modal v-on:ok="save_phone_number">
// Remainder of modal code omitted for clarity
save_phone_number: function(bvModalEvt) {
    bvModalEvt.preventDefault()
    // do other things here and manually close the modal when done

However, I need to pass some additional arguments. I tried the following, where second and third are the other arguments I'm passing.

<b-modal v-on:ok="save_phone_number(bvModalEvt, second, third)">
save_phone_number: function(bvModalEvt, second, third) {
    bvModalEvt.preventDefault()
    // do other things here and manually close the modal when done

When I run that, I receive an error when I call preventDefault() that I cannot call preventDefault() on undefined.

I also tried $bvModalEvt in the event binding.

How can I pass bvModalEvt to the function along with other variables?

the bvevent object is the first argument emitted by the ok, cancel, and hide events. So you can use Vue's special $event variable (which is the first argument emitted by an event... and not necessarily a native event object, which it is commonly used for):

<b-modal v-on:ok="save_phone_number($event, second, third)">

$event will contain the bvModal event object.