【问题标题】:vue-model in Vue.2.xVue.2.x 中的 vue-model
【发布时间】:2017-08-01 14:04:52
【问题描述】:

https://www.npmjs.com/package/vue-model

上述代码的示例在我的环境中不起作用:

vue: ^2.2.1,

vue-model": 0.0.3,

    Vue.models.register('customer', {
        baseRoute: '/customers'
    });

通过上述示例注册客户模型后, 我应该能够引用客户对象,

    customer.$.update()

但错误返回,

http://eslint.org/docs/rules/no-undef“客户”未定义
/Users/murotanimari/my-project/src/components/Scene1.vue:19:1 客户.$.update() ^

我假设注册到 vue 模型失败... 有人知道这次失败的原因吗?

【问题讨论】:

  • 尝试使用“this.customer”?顺便说一句,这是一个很少使用的模块,所以你最好在它的 github repo 的“问题”列表中提出这个问题。
  • 你在哪里打电话 customer.$.update() ?通常,当在 Vue 实例上注册事物时,您必须调用 this.$customer 或 this.$models.customer 或类似的名称。您能否提供其余代码以及您是如何使用它的?

标签: vue.js vuejs2


【解决方案1】:

我认为这个库不支持 vue2。你可以试试vue-resouce。不支持类似模型的操作,但是使用起来真的很方便。

【讨论】:

    猜你喜欢
    • 2020-11-11
    • 2019-05-22
    • 2019-02-04
    • 1970-01-01
    • 2021-06-07
    • 2021-04-08
    • 1970-01-01
    • 2021-05-14
    • 2017-06-30
    相关资源
    最近更新 更多