【发布时间】:2019-03-27 19:31:00
【问题描述】:
是否可以将自定义错误添加到 ErrorBag 中
我正在使用 nuxtjs。我已经通过 nuxt.config.js 将 vee-validate 注册到我的插件中
不过效果很好
我想在模板中使用相同的错误代码
例如:
<template>
<div v-if="errors.all().length>0">
//loop through
</div>
</template>
我正在使用 axios 来获取用户信息。 如果请求没有返回我预期的数据集。我在想我可以简单地
this.errors.push('this is my error message') //-> or some variant of this
当我这样做时,我知道 this.errors.push 不是函数
我知道
this.errors = ErrorBag{ __ob__: Observer} //-> has items and a vmId attributes
如果我修改代码以推送到 ErrorBag 上,我会得到未定义的推送
【问题讨论】:
标签: vue.js vuejs2 vee-validate