【发布时间】:2019-01-28 06:46:36
【问题描述】:
错误:
[Vue 警告]:属性或方法“$v”未在实例上定义,但 在渲染期间引用。确保此属性是反应性的, 无论是在数据选项中,还是对于基于类的组件,通过 初始化属性。看: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
发现于
---> 在 resources\assets\js\components\products\Product_create.vue
我使用 Vue.js 和 Vuelidate 作为验证器, 我已经从这里https://jsfiddle.net/Frizi/b5v4faqf/ 复制并粘贴了这段代码,但它仍然不起作用:
Vue 组件:
<template >
<input v-model="$v.text.$model" :class="status($v.text)">
<!-- <pre>{{ $v }}</pre> -->
</template>
<script>
import { required, minLength, between } from 'vuelidate/lib/validators'
export default {
data() {
return {
text: ''
}
},
validations: {
text: {
required,
minLength: minLength(5)
}
},
methods: {
status(validation) {
return {
error: validation.$error,
dirty: validation.$dirty
}
}
}
}
</script>
App.js
require('./bootstrap');
window.Vue = require('vue');
window.VueRouter = require('vue-router').default;
window.VueAxios = require('vue-axios').default;
window.Axios = require('axios').default;
window.VueFormWizard = require('vue-form-wizard');
window.Vuelidate = require('vuelidate').default;
import 'vue-form-wizard/dist/vue-form-wizard.min.css';
Vue.use(VueRouter,VueAxios,axios,VueFormWizard,Vuelidate);
const ProductOptionCreate = Vue.component('po-create',require('./components/products/ProductOption_create.vue'));
const ProgressModal = Vue.component('vue-modal',require('./components/ProgressModal.vue'));
const ProductIndex = Vue.component('product-list',require('./components/products/Product_index.vue'));
const productshow = Vue.component('productshow',require('./components/products/ProductOption_show.vue'));
const ProductCreate = Vue.component('product-create',require('./components/products/Product_create.vue'));
const app = new Vue({
el:'#app',
});
这段代码有什么问题?
【问题讨论】:
-
你没有定义$v,应该在App.js下定义
-
@RodrigoMata 你能告诉我它是如何工作的吗?
-
据我所知,
Vue.use()只接受 一个 参数。您正试图通过它五个。 -
抱歉,
Vue.use()采用 一个 或 两个 参数,第一个是必需的插件,第二个是可选的配置对象 -
哦,好的,非常感谢兄弟,如果我有五个呢?我该怎么办? @菲尔
标签: vue.js