通过接口获取的经纬度信息,怎么从prop里面拿出来呢?现在默认位数太长,需要对其进行截取只保留小数点后4位,但是拿不到值,求解
<el-table-column prop="lat" label="纬度" header-align="center" align="center"></el-table-column>
<el-table-column prop="lng" label="经度" header-align="center" align="center"></el-table-column>
1、通过接口返回数据的地方进行数据修改,修改时需要对整个表格数据进行循环修改
2、使用element自定义模板,直接在el-table-column修改
<el-table-column prop="lat" label="纬度" header-align="center" align="center">
<template slot-scope="scope">
{{scope.lat.toFixed(4)}} //四舍五入保留四位小数
</template>
</el-table-column>
你好,如有帮助,请采纳
方法一:
所以就可以直接拿取
mounted() {
let _this=this;
let {datas,status}=_this._props;
console.log(datas,999999);
},
方法二:
有时候会获取不到,这时候可以用一个定时器来获取
mounted() {
let _this=this;
let {datas,status}=_this._props;
setTimeout(()=>{
console.log(this._props)
console.log(datas,111111)
},2000)
}
方法三:
深拷贝
mounted() {
let _this=this;
let props={..._this._props};
console.log(props,"props.......")
},