英文:
Why Invalid prop: type check failed for prop "value". Expected String, Number, Object, Boolean, got Array shows for the program below mention?
问题
无效的属性:类型检查失败,期望 String、Number、Object、Boolean,而传入了 Array。在下面提到的程序中显示了这个错误:
html:
<model-select :options="usersAssignData" v-model="userNameData" class="form-control col-sm-4" @keyup.native="getUser">
script:
getUser(e) {
console.log("idd", this.selectedZone)
var user = e.target.value;
axios.get("/helpdesk/getUsers", {
params: {
q: user,
account_id: this.selectedZone,
searchOption: 'username'
},
headers: {
'Authorization': localStorage.getItem('token')
}
})
.then(response => {
this.usersAssignData = response.data
})
.catch(error => {
reject(error);
console.log(error);
});
}
英文:
Why Invalid prop: type check failed for prop "value". Expected String, Number, Object, Boolean, got Array shows for the program below mention?
html:
<model-select :options="usersAssignData" v-model="userNameData" class="form-control col-sm-4" @keyup.native="getUser" >
script:
getUser(e) {
console.log("idd",this.selectedZone)
var user = e.target.value;
axios.get("/helpdesk/getUsers", {
params: {
q: user,
account_id: this.selectedZone,
searchOption: 'username'
},
headers: {
'Authorization': localStorage.getItem('token')
}
})
.then(response => {
this.usersAssignData = response.data
})
.catch(error => {
reject(error);
console.log(error);
});
}
答案1
得分: 3
usersAssignData
属性的类型可能不是一个数组,而axios调用似乎返回了一个数组。尝试按照@DharaParmar所说的方式将属性的类型设置为数组。
英文:
The type of the prop usersAssignData
of your component is probably not an Array, and the axios call it seems to be returning an Array. Try doing what @DharaParmar said, setting the type of the prop as an array.
答案2
得分: 2
Sure, here is the translated code:
## 请尝试在要使用您的 props 值的文件中使用以下代码 ##
<script>
export default {
props: {
usersAssignData: {
type: Array,
default: () => [],
},
}
}
</script>
I hope this helps! If you have any more code to translate, please feel free to provide it.
英文:
Try using the below code in file which you want to use your props value
<script>
export default {
props: {
usersAssignData: {
type: Array,
default: () => [],
},
},
}
</script>
答案3
得分: -1
这对我有效:
data() {
return {
usersAssignData: 数组/对象/字符串/数字,
}
}
现在 usersAssignData 可以是数组、对象、字符串或数字,你不会再看到那个错误了
英文:
hey this works for me:
data() {
return {
usersAssignData:Array/Object/String/Number,
}
}
now usersAssignData can be Array or Object or String Or Number and your not gonna see that error anymore
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论