vue.js - Vuejs 转换 v-on :enter. "done"回调是什么?

标签 vue.js vuejs2

我需要将额外的参数传递给“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/

相关文章:

javascript - 在 VueJS 中使用全局辅助函数

javascript - 模型 Laravel 和 Vue 上的自定义方法

css - 在 Vuetify 中动态更改工具栏的颜色

vue.js - 在不使用 'v-model' 的情况下设置 <select> 的值

javascript - 如何在 vue 组件中显示所需的 html 5?

vue.js - Nuxtjs如何在所有sass文件中添加全局环境变量

php - Vuejs 从 PHP/MySQL 获取请求不起作用

vue.js - 如何切换单个 <li> 元素的类?

css - Vue.js CSS 包优先级(?)

vue.js - vue-router 重定向到默认路径问题