Javascript 更改/更新Vue中的属性

Javascript 更改/更新Vue中的属性,javascript,vue.js,Javascript,Vue.js,我是Vue的新手,我想知道我是否能做到这一点。以下是代码: <template> <modal :name="fruit" :opened="opened" :closed="onClose"> ...code in here </modal> </template> :在绑定到函数时关闭,因此onClose和onComplete都表示函数。是否有一种有效的动态更新方法:关闭 我认为一个很好的解决方案是添加一个标志变量

我是Vue的新手,我想知道我是否能做到这一点。以下是代码:

<template>
    <modal :name="fruit" :opened="opened" :closed="onClose">

    ...code in here

    </modal>
</template>

:在绑定到函数时关闭,因此onClose和onComplete都表示函数。是否有一种有效的动态更新方法:关闭

我认为一个很好的解决方案是添加一个标志变量,如

new Vue({
  // ...
  data: {
    condition: false
  }
})
然后在需要时进行更新,如:

vm.condition = true;
在UI中使用以下逻辑:

<modal :name="fruit" :opened="opened" 
    v-bind="{ closed: condition ? onComplete : onClose }">

很高兴它有帮助!
<modal :name="fruit" :opened="opened" 
    v-bind="{ closed: condition ? onComplete : onClose }">