# 添加count的类型判断

This commit is contained in:
xianfuxing 2018-09-24 22:22:41 +08:00
parent be79586a4d
commit 08ca34945d
1 changed files with 9 additions and 8 deletions

View File

@ -62,12 +62,12 @@ import { fetchDeviceList, fetchDeviceLogsHistory } from '@/api/counter'
import Screen from './components/screen'
import Chart from './components/chart'
const defaultLastItem = {
mosq_count: '0',
status: '0',
signal: '0',
energy: '0'
}
// const defaultLastItem = {
// count: '0',
// status: '0',
// signal: '0',
// energy: '0'
// }
export default {
name: 'deviceDetail',
components: {
@ -117,8 +117,9 @@ export default {
fetchDeviceList(params).then(response => {
this.deviceList = response.data.results
this.lastItem = this.deviceList[0]
if (this.lastItem === undefined) {
this.lastItem = defaultLastItem
console.log(typeof (this.lastItem.count))
if (typeof (this.lastItem.count) === 'number') {
this.lastItem.count = this.lastItem.count.toString()
}
this.flag = true
})