我使用 vue-cli
作为前端,使用 express
作为后端。我的后端数据的处理时间是 1.7 秒,如果我在 mounted ()
下执行请求,vue 已经读取了 data ()
并向我发出警告,它正在等待其他类型并且无法进行排序等。
有没有办法在不发出警告的情况下执行此操作?
这是我的 html 部分:
<v-data-table
class="ownstyle"
:headers="headers"
:items="orders"
>
<template slot="items" slot-scope="props">
<td >{{ props.item.value1 }}</td>
<td >{{ props.item.value2 }}</td>
...
</template>
</v-data-table>
这是脚本部分:
data () {
return {
headers: [
{ text: 'name1', value: 'value1', ...},
{ text: 'name2', value: 'value2', ...},
...
],
orders: ''
}
},
mounted () {
ApiService.orders().then(
response => (this.orders = response.data))
}
最佳答案
数据表期望通过:items="orders"
传递的orders变量是一个数组。您在此处将其定义为字符串 orders: ''
。您可能想使用 orders: []
来代替。
关于node.js - Vue.js 抛出多个警告 : Invalid prop: type check failed for prop "items". 预期数组,得到值为 ""的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54647337/