Vuejs2 如何将Axios与Vue Multiselect配合使用?

Vuejs2 如何将Axios与Vue Multiselect配合使用?,vuejs2,vue-multiselect,Vuejs2,Vue Multiselect,使用Vue Multiselect的新功能。我使用axios从JSON占位符执行GET请求以进行测试 如何在下拉列表中显示标题和帖子id 现在,我的选择框中显示了[Object]-[title] {{value}} 从“vue Multiselect”导入Multiselect; 从“axios”导入axios; 导出默认值{ //或在本地注册 组件:{Multiselect}, 数据(){ 返回{ 值:null, 员额:[] }; }, 创建(){ 这是getPosts(); }, 方法:

使用Vue Multiselect的新功能。我使用axios从JSON占位符执行GET请求以进行测试

如何在下拉列表中显示标题和帖子id

现在,我的选择框中显示了[Object]-[title]


{{value}}
从“vue Multiselect”导入Multiselect;
从“axios”导入axios;
导出默认值{
//或在本地注册
组件:{Multiselect},
数据(){
返回{
值:null,
员额:[]
};
},
创建(){
这是getPosts();
},
方法:{
getPosts(){
axios
.get(“https://jsonplaceholder.typicode.com/posts")
。然后(响应=>{
//eslint禁用下一行
控制台日志(响应);
this.posts=response.data;
})
.catch(错误=>{
//eslint禁用下一行
console.log(错误);
});
},
postWithTitle(id,标题){
返回`${id}-[${title}]`;
}
}
};
修复:

  postWithTitle(option) {
     return `${option.id} - [${option.title}]`;
  }
解释:

  postWithTitle(option) {
     return `${option.id} - [${option.title}]`;
  }
当我在
postWithTitle
函数中简单地
console.log
ged时,我看到:

自定义
自定义标签
属性正在接受一个只接受一个参数的回调。该参数是整个
选项
对象-您的
帖子
数组的单个条目。

修复:

  postWithTitle(option) {
     return `${option.id} - [${option.title}]`;
  }
解释:

  postWithTitle(option) {
     return `${option.id} - [${option.title}]`;
  }
当我在
postWithTitle
函数中简单地
console.log
ged时,我看到:

自定义
自定义标签
属性正在接受一个只接受一个参数的回调。该参数是整个
选项
对象-您的
帖子
数组的单个条目