我在本地文件中获取了一些 json 数据,该文件是 .txt 文件,并且无法直接访问数据,因此我只是将文件格式更改为 .json,之后,我尝试使用下面的代码循环获取干净的数据。
我通过在此组件中计算来获取数据,但我想将此干净数据设置为子组件的道具。
我想用干净的数据创建许多子组件。
非常感谢您!
代码:
<script>
export default {
name: 'Dashboard',
components : {
'my-table': mytable,
'my-search': search,
},
data: function() {
return {
casesDataList: [],
};
},
computed:{
ClearList: function(){
var casesDataList = this.casesDataList.map(function (neo){
return {ID: neo.Attributes[1].Value, Date: neo.FormattedValues[0].Value, Owner: neo.FormattedValues[1].Value};
});
return casesDataList;
}
},
created: function(){
this.getCasesData();
},
methods: {
getCasesData() {
fetch("Weather.json")
.then(response => response.json())
.then(data => (this.casesDataList = data.Entities));
},
}
};
</script>