Vue.js 如何将阵列数据加载到Vuetify Select输入
我试图在vuetify select组件中显示位置,但我当前的代码呈现的是[object object],而不是位置1、位置2等 我的选择组件:Vue.js 如何将阵列数据加载到Vuetify Select输入,vue.js,vuex,vuetify.js,Vue.js,Vuex,Vuetify.js,我试图在vuetify select组件中显示位置,但我当前的代码呈现的是[object object],而不是位置1、位置2等 我的选择组件: <v-select :items="locations" v-model="location" label="Choose Location" bottom autocomplete ></v-select> Vuex Getter: getLocationsForEvent: (state) => (id) =>
<v-select
:items="locations"
v-model="location"
label="Choose Location"
bottom
autocomplete
></v-select>
Vuex Getter:
getLocationsForEvent: (state) => (id) => {
return state.loadedLocations.filter(function (location) {
return location.eventId === id;
});
}
以下是位置数据的屏幕截图:
谢谢 对于自定义对象,必须指定项目文本。项目文本是每个选项将显示的内容 例如,从您的屏幕截图中,标题可能是一个属性: 下面是演示 无项目文本: 新Vue{ el:“应用程序”, 资料{ 返回{ 位置:空, 地点:[ {id:1111,经理:'Alice',头衔:'Water Cart 1'}, {id:2222,经理:'Bob',职务:'Water Cart 2'}, {id:3333,经理:'Neysa',头衔:'Water Cart 3'} ] } } }
实现了一个具有低级对象数组的手表
watch: {
groupInfo: function(groupInfo) {
if (groupInfo.teams !== undefined) {
var newArray = [];
for (var key in groupInfo.teams) {
var obj = groupInfo.teams[key];
newArray.push(obj);
}
console.log("wagwan" newArray)
this.teams = newArray;
}
}
},
给出函数getLocationsForEvent返回的数据示例。我添加了实际数据的屏幕截图。是否可以使用两个属性?比如头衔和经理?@KeinGenie我不知道。我认为在这种情况下,您必须使用title和manager创建计算的派生属性结果,并将该属性用作项文本。
watch: {
groupInfo: function(groupInfo) {
if (groupInfo.teams !== undefined) {
var newArray = [];
for (var key in groupInfo.teams) {
var obj = groupInfo.teams[key];
newArray.push(obj);
}
console.log("wagwan" newArray)
this.teams = newArray;
}
}
},