@ -283,7 +283,14 @@ export default {
this . deviceTitle = JSON . parse ( deviceInfoVal ) ;
this . deviceTitle = JSON . parse ( deviceInfoVal ) ;
} else {
} else {
/ / 否 则 , 使 用 r e s . d a t a [ 0 ] . i d
/ / 否 则 , 使 用 r e s . d a t a [ 0 ] . i d
this . deviceTypeVal = res . data [ 0 ] ? . id ; / / 使 用 可 选 链 操 作 符 避 免 r e s . d a t a [ 0 ] 为 u n d e f i n e d 的 情 况
/ / t h i s . d e v i c e T y p e V a l = r e s . d a t a [ 0 ] ? . i d ; / / 使 用 可 选 链 操 作 符 避 免 r e s . d a t a [ 0 ] 为 u n d e f i n e d 的 情 况 低 版 本 不 认 识
this . deviceTypeVal =
res . data &&
Array . isArray ( res . data ) &&
res . data . length > 0 &&
res . data [ 0 ] !== null
? res . data [ 0 ] . id
: undefined ;
this . deviceTitle = res . data [ 0 ] . mc ;
this . deviceTitle = res . data [ 0 ] . mc ;
/ / 同 时 , 将 新 获 取 的 a r e a V a l 存 储 到 l o c a l S t o r a g e 中
/ / 同 时 , 将 新 获 取 的 a r e a V a l 存 储 到 l o c a l S t o r a g e 中
localStorage . setItem (
localStorage . setItem (
@ -368,7 +375,11 @@ export default {
this . areaVal = JSON . parse ( storedAreaVal ) ;
this . areaVal = JSON . parse ( storedAreaVal ) ;
} else {
} else {
/ / 否 则 , 使 用 r e s . d a t a [ 0 ] . i d
/ / 否 则 , 使 用 r e s . d a t a [ 0 ] . i d
this . areaVal = res . data [ 0 ] ? . id ; / / 使 用 可 选 链 操 作 符 避 免 r e s . d a t a [ 0 ] 为 u n d e f i n e d 的 情 况
this . areaVal =
res . data && res . data . length > 0 && res . data [ 0 ] !== null
? res . data [ 0 ] . id
: undefined ;
/ / 同 时 , 将 新 获 取 的 a r e a V a l 存 储 到 l o c a l S t o r a g e 中
/ / 同 时 , 将 新 获 取 的 a r e a V a l 存 储 到 l o c a l S t o r a g e 中
localStorage . setItem ( "areaVal" , JSON . stringify ( this . areaVal ) ) ;
localStorage . setItem ( "areaVal" , JSON . stringify ( this . areaVal ) ) ;