后台读取了四条数据数据是List形式,传到前台是四个array,没想到直接关联到v-model="dataForm.xxx"的方法。
在service层中,读取完数据库数据之后把list遍历到map对象里,这样就能直接从一个map里找到Value对应的键名。
public HashMap<String, String> getPrice(Integer Type) {
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("Id", SecurityUtils.getAgencyId());
param.put("Type", settingType);
List<PSetting> settinglist = settingMapper.selectByExample(param);//取数据
HashMap<String, String> priceSettings = new HashMap<String, String>();
for (PSetting s : settinglist) {
priceSettings.put(s.getSettingKey(), s.getSettingValue());//遍历
}
return priceSettings;
}
Vue里
methods: {
// 获取信息
priceSelect: function () {
priceApi.priceSelect().then((res) => {
console.log('res')
console.log(res)
this.dataForm = res.data
})
},
v-model="dataForm.normal"