我需要将额外的参数传递给“v-on:enter”钩子(Hook):
<transition v-on:enter="stretch($event,done?,{opacity:1,width:'400px')"></transition>
...在我的 Vue 中
methods:{
stretch: function (properties,el,done) {
var delay = el.dataset.index * 150
setTimeout(function () {
Velocity(
el,
properties,
{ complete: done }
)
}, delay)
},
它不起作用,因为我不知道如何显式传递 done 回调(对于钩子(Hook) enter 是强制的)
什么有效但不可重用:
<transition v-on:enter="stretch"></transition>
...
methods:{
stretch: function (el,done) {
var delay = el.dataset.index * 150
setTimeout(function () {
Velocity(
el,
{ opacity: 1, width: 400px },
{ complete: done }
)
}, delay)
},
文档中的链接:https://v2.vuejs.org/v2/guide/transitions.html#JavaScript-Hooks
有人可以帮助我吗?提前致谢。
最佳答案
解决方案:
<transition v-on:enter="stretch(arguments, {opacity:1,width:'400px'})">`</transition>
methods: {
stretch(args, properties) {
// args[0] === el
// args[1] === done()
}
}
希望它能发挥作用。
关于vue.js - Vuejs 转换 v-on :enter. "done"回调是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43010033/