vue-template-babel-compiler icon indicating copy to clipboard operation
vue-template-babel-compiler copied to clipboard

[Fixed Bug] argument undefined in function call of scoped slot

Open csechuan opened this issue 3 years ago • 3 comments

Facing some issue when running this compiler in Nuxt. Trying to call a function on click of a component, but unable to retrieve the argument.

<component @click.prevent(greet('hello'))>

methods: { greet(message) { console.log(message) // return undefined } }

csechuan avatar Aug 01 '21 13:08 csechuan

As far as I konw,

First, you should use click listener with ="method", just like below, according to vue.js Document

  <div @click.prevent="greet('hello')">worked</div>

Then it will work as you expect, get your param: 0PYR) R)Q{BZYKVSFB5SQ1Y

Second, if you are using event listener of component, the usage is different, please refre to Listening to Child Components Events

Hope my reply is helpeful, Thank you for your feedback~

JuniorTour avatar Aug 01 '21 15:08 JuniorTour

I am using bootstrap-vue table. It behaves weirdly if i use this compiler.

<b-table :items="items">
  <template #cell(more)="{ item }">
    <b-button @click.prevent="greet(item)">test</b-button>  <!-- item is undefined -->
    <b-link :to="getLink(item)"></b-link> <!-- item is NOT undefined and has values -->
  </template>
</b-table>

But when i run the above code without this compiler, it just works fine.

csechuan avatar Aug 01 '21 18:08 csechuan

@csechuan It is a bug, I've published a new version 1.0.1 to fix.

You can try it by:

npm install [email protected] -D
// or yarn
yarn add [email protected] -D

U{3IWFA3A~WP84Y8YL @{YA

Thank you for your feedback!

JuniorTour avatar Aug 08 '21 07:08 JuniorTour