Vuex-ORM 的双向数据绑定 [英] Two way data binding with Vuex-ORM

查看:52
本文介绍了Vuex-ORM 的双向数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在使用 Vuex ORM?

我找到了几个库来帮助 Vuex 解决这个问题,但还没有专门针对 Vuex-ORM 的:

I've found a couple of libraries for helping with this with Vuex, but none specifically for Vuex-ORM yet:

推荐答案

我不认为有任何预定义的插件可以做到这一点,但是您应该能够在计算时使用 setter 和 getter 对典型的 Vuex 状态执行相同的操作财产...?

I don't think there is any predefined plugin to do this, but you should be able to do the same for typical Vuex states using setter and getter on computed property...?

import User from '@/models/User'

export default {
  computed: {
    user: {
      get () {
        return User.find(1)
      },

      set (value) {
        User.update({
          where: 1,
          data: {
            name: value
          }
        })
      }
    }
  }
}

这篇关于Vuex-ORM 的双向数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆