【问题标题】:"error" is not defined on the instance but referenced during render“错误”未在实例上定义,但在渲染期间引用
【发布时间】:2019-12-08 19:22:53
【问题描述】:

使用 Laravel 和 vue 设置并希望在某些表单上使用 vee-validate

我通过 NPM 安装,然后添加了我的 app.js

import VeeValidate from 'vee-validate'
Vue.use(VeeValidate);

也试过了

window.VeeValidate = require('vee-validate');
Vue.use(window.VeeValidate);

在我的组件中

<div class="form-group">
          <label for="exampleInputEmail1">Username</label>
          <input
            v-model="username"
            v-validate="'required|max:16'"
            data-vv-name="username"
            type="text"
            class="form-control"
            id="exampleInputEmail1"
            aria-describedby="Username"
          />
          <small>{{error.first('username')}}</small>
        </div>

我得到了错误

[Vue warn]: Property or method "error" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

【问题讨论】:

    标签: vue.js vue-component vue-router vee-validate


    【解决方案1】:

    验证器错误对象是错误。因此应该是错误而不是错误。

     <small>{{errors.first('username')}}</small>
    

    【讨论】:

    • 太棒了,当它发生时我会喜欢它,谢谢
    • @GrahamMorbyDev 请接受答案并关闭问题。
    • 噢……你救了我的命!!完美的解决方案...谢谢...@Riddhi
    猜你喜欢
    • 2017-02-13
    • 2017-02-17
    • 2018-12-24
    • 2023-01-03
    • 2020-09-15
    • 2018-03-28
    • 1970-01-01
    • 2017-06-16
    • 2018-06-22
    相关资源
    最近更新 更多