Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 如何使用axios中的数据填充Vuetify Select_Vue.js_Html Select_Axios_Vuetify.js - Fatal编程技术网

Vue.js 如何使用axios中的数据填充Vuetify Select

Vue.js 如何使用axios中的数据填充Vuetify Select,vue.js,html-select,axios,vuetify.js,Vue.js,Html Select,Axios,Vuetify.js,我需要填充Vuetify select,但它有一个问题,我的Get方法返回数据,但Vuetify select仅显示如下内容: 文本显示有效数据: [ { "id": 1 }, { "id": 2 } ] 要填充Select,请按照文档添加:items=“entidades”和:item text=“entidades.id”和:item value=“entidades.id” 我已经试过放0,但结果是一样的 我的axios.get方法 axios.get('http://loca

我需要填充Vuetify select,但它有一个问题,我的Get方法返回数据,但Vuetify select仅显示如下内容:

文本显示有效数据:

[ { "id": 1 }, { "id": 2 } ]
要填充Select,请按照文档添加
:items=“entidades”和:item text=“entidades.id”和:item value=“entidades.id”

我已经试过放0,但结果是一样的

我的axios.get方法

    axios.get('http://localhost:58209/api/GetEntidades', {
      headers:{
       "Authorization": "Bearer "+localStorage.getItem('token')
          }
  })
    .then(response => { 
      console.log(response)
      this.entidades = response.data;
        })
        .catch(error => {
        console.log(error.response)
        });

非常感谢

项目文本
项目值
分别是每个项目将显示和用作值的属性的名称。因此,请使用
item text=“id”item value=“id”



Hi,是相同的结果,但带有警告:属性或方法“id”未在实例上定义,而是在渲染期间引用。通过初始化属性,确保此属性在数据选项或基于类的组件中是被动的。我不知道,但我复制了您的属性,现在它可以工作了,我想这是因为我使用了:项文本,而您使用的项文本没有:是,没有
。使用
:item text=“someValue”
时,它将在当前范围内查找
someValue
变量。在您的例子中,您可能使用了
:item text=“id”
,并且可能出现了错误,因为当前范围中不应该有
id
变量(
id
是每个
entidade
的属性,而不是它自己的变量)。
`data() {
return(){
entidades: [{
          id: ''  
        }],
}
}`
    axios.get('http://localhost:58209/api/GetEntidades', {
      headers:{
       "Authorization": "Bearer "+localStorage.getItem('token')
          }
  })
    .then(response => { 
      console.log(response)
      this.entidades = response.data;
        })
        .catch(error => {
        console.log(error.response)
        });
<v-select :items="entidades" item-text="id" item-value="id" single-line auto prepend-icon="group_work" label="Seleccionar Grupo"></v-select>