我这里接口当中这个字段有数据,前端代码当中也写的是对的,但是页面显示是undefined,这个是为什么



看这个应该是字段名称取错了吧
1、写代码尤其是table表格这一类的记得刷新数据缓存
2、在table的其他单元 使用插槽打印此数据 如果是正常的可以考虑用插槽实现
3、如果2不行、则考虑更新数据的格式 处理为字符串展示 防止由于页面某些逻辑导致数据错乱
可能原因:
解决方案:
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
// 在发送请求之前做些什么 加载中的图片放在这里即可
return config;
}, function (error) {
// 对请求错误做些什么
return Promise.reject(error);
});
<template>
<view>
<view v-if="dataLoaded">
{{data}}
</view>
<view v-else>
数据加载中……
</view>
</view>
</template>
watch:{
data:function(val,oldval){
if(val!==oldval){
this.dataLoaded = true
}
}
},
<template>
// ...
<div v-for="(item,$index) in repetitionList" class="main" :key="$index">
{{item}}
</div>
// ...
</template>
<script>
export default {
data(){
return{
repetitionList: [],
item: {},
}
},
methods: {
// ...
insertItemIntoList: function(){
var newItem = {...this.item};
this.repetitionList.push(newItem);
}
},
}
</script>