TypeError: Cannot read property 'length' of null

本文为博主原创,未经允许不得转载:

异常展示:

[Vue warn]: Error in getter for watcher "filterAndSortData": "TypeError: Cannot read property 'length' of null"

found in

---> <UxTable>
       <UxCol>
         <UxRow>
           <CustomerDomainCofigDetail> at src/web/manage/customerManage/CustomerDomainCofigDetail.vue
             <ElMain>
               <ElContainer>
                 <MainAdmin> at src/web/manage/MainAdmin.vue
                   <App> at src/app.vue
                     <Root>
warn @ vue.esm.js?efeb:591
logError @ vue.esm.js?efeb:1737
globalHandleError @ vue.esm.js?efeb:1732
handleError @ vue.esm.js?efeb:1721
get @ vue.esm.js?efeb:3145
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
Promise.then (async)
microTimerFunc @ vue.esm.js?efeb:1806
nextTick @ vue.esm.js?efeb:1850
queueWatcher @ vue.esm.js?efeb:3068
update @ vue.esm.js?efeb:3209
notify @ vue.esm.js?efeb:697
reactiveSetter @ vue.esm.js?efeb:1014
proxySetter @ vue.esm.js?efeb:3300
(anonymous) @ CustomerDomainCofigDetail.vue?6300:488
Promise.then (async)
initData @ CustomerDomainCofigDetail.vue?6300:482
created @ CustomerDomainCofigDetail.vue?6300:627
callHook @ vue.esm.js?efeb:2921
Vue._init @ vue.esm.js?efeb:4630
VueComponent @ vue.esm.js?efeb:4798
createComponentInstanceForVnode @ vue.esm.js?efeb:4310
init @ vue.esm.js?efeb:4131
createComponent @ vue.esm.js?efeb:5608
createElm @ vue.esm.js?efeb:5555
updateChildren @ vue.esm.js?efeb:5845
patchVnode @ vue.esm.js?efeb:5936
patch @ vue.esm.js?efeb:6096
Vue._update @ vue.esm.js?efeb:2670
updateComponent @ vue.esm.js?efeb:2788
get @ vue.esm.js?efeb:3142
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
vue.esm.js?efeb:1741 TypeError: Cannot read property 'length' of null
    at recursiveRows (utils.js?8c28:43)
    at normalizeRows (utils.js?8c28:61)
    at VueComponent.normalizeData (table.js?7ae6:141)
    at Watcher.get (vue.esm.js?efeb:3142)
    at Watcher.evaluate (vue.esm.js?efeb:3249)
    at VueComponent.computedGetter [as normalizeData] (vue.esm.js?efeb:3507)
    at VueComponent.filterAndSortData (table.js?7ae6:180)
    at Watcher.get (vue.esm.js?efeb:3142)
    at Watcher.evaluate (vue.esm.js?efeb:3249)
    at VueComponent.computedGetter [as filterAndSortData] (vue.esm.js?efeb:3507)
logError @ vue.esm.js?efeb:1741
globalHandleError @ vue.esm.js?efeb:1732
handleError @ vue.esm.js?efeb:1721
get @ vue.esm.js?efeb:3145
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
Promise.then (async)
microTimerFunc @ vue.esm.js?efeb:1806
nextTick @ vue.esm.js?efeb:1850
queueWatcher @ vue.esm.js?efeb:3068
update @ vue.esm.js?efeb:3209
notify @ vue.esm.js?efeb:697
reactiveSetter @ vue.esm.js?efeb:1014
proxySetter @ vue.esm.js?efeb:3300
(anonymous) @ CustomerDomainCofigDetail.vue?6300:488
Promise.then (async)
initData @ CustomerDomainCofigDetail.vue?6300:482
created @ CustomerDomainCofigDetail.vue?6300:627
callHook @ vue.esm.js?efeb:2921
Vue._init @ vue.esm.js?efeb:4630
VueComponent @ vue.esm.js?efeb:4798
createComponentInstanceForVnode @ vue.esm.js?efeb:4310
init @ vue.esm.js?efeb:4131
createComponent @ vue.esm.js?efeb:5608
createElm @ vue.esm.js?efeb:5555
updateChildren @ vue.esm.js?efeb:5845
patchVnode @ vue.esm.js?efeb:5936
patch @ vue.esm.js?efeb:6096
Vue._update @ vue.esm.js?efeb:2670
updateComponent @ vue.esm.js?efeb:2788
get @ vue.esm.js?efeb:3142
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
vue.esm.js?efeb:591 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"

found in

---> <UxTable>
       <UxCol>
         <UxRow>
           <CustomerDomainCofigDetail> at src/web/manage/customerManage/CustomerDomainCofigDetail.vue
             <ElMain>
               <ElContainer>
                 <MainAdmin> at src/web/manage/MainAdmin.vue
                   <App> at src/app.vue
                     <Root>
warn @ vue.esm.js?efeb:591
logError @ vue.esm.js?efeb:1737
globalHandleError @ vue.esm.js?efeb:1732
handleError @ vue.esm.js?efeb:1721
Vue._render @ vue.esm.js?efeb:4546
updateComponent @ vue.esm.js?efeb:2788
get @ vue.esm.js?efeb:3142
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
Promise.then (async)
microTimerFunc @ vue.esm.js?efeb:1806
nextTick @ vue.esm.js?efeb:1850
queueWatcher @ vue.esm.js?efeb:3068
update @ vue.esm.js?efeb:3209
notify @ vue.esm.js?efeb:697
reactiveSetter @ vue.esm.js?efeb:1014
proxySetter @ vue.esm.js?efeb:3300
(anonymous) @ CustomerDomainCofigDetail.vue?6300:488
Promise.then (async)
initData @ CustomerDomainCofigDetail.vue?6300:482
created @ CustomerDomainCofigDetail.vue?6300:627
callHook @ vue.esm.js?efeb:2921
Vue._init @ vue.esm.js?efeb:4630
VueComponent @ vue.esm.js?efeb:4798
createComponentInstanceForVnode @ vue.esm.js?efeb:4310
init @ vue.esm.js?efeb:4131
createComponent @ vue.esm.js?efeb:5608
createElm @ vue.esm.js?efeb:5555
updateChildren @ vue.esm.js?efeb:5845
patchVnode @ vue.esm.js?efeb:5936
patch @ vue.esm.js?efeb:6096
Vue._update @ vue.esm.js?efeb:2670
updateComponent @ vue.esm.js?efeb:2788
get @ vue.esm.js?efeb:3142
run @ vue.esm.js?efeb:3219
flushSchedulerQueue @ vue.esm.js?efeb:2981
(anonymous) @ vue.esm.js?efeb:1837
flushCallbacks @ vue.esm.js?efeb:1758
vue.esm.js?efeb:1741 TypeError: Cannot read property 'length' of null
    at recursiveRows (utils.js?8c28:43)
    at normalizeRows (utils.js?8c28:61)
    at VueComponent.normalizeData (table.js?7ae6:141)
    at Watcher.get (vue.esm.js?efeb:3142)
    at Watcher.evaluate (vue.esm.js?efeb:3249)
    at VueComponent.computedGetter [as normalizeData] (vue.esm.js?efeb:3507)
    at VueComponent.spinClasses (table.js?7ae6:313)
    at Watcher.get (vue.esm.js?efeb:3142)
    at Watcher.evaluate (vue.esm.js?efeb:3249)
    at Proxy.computedGetter (vue.esm.js?efeb:3507)

该异常原因:由于在页面加载数据初始化的时候,定义了一个数组的数据类型,从后台获取数据初始化给该变量赋值,由于后台返回数据为null,将其赋值给数组的时候就报错了,

解决方法:在赋值的时候加一层为空的判断和校验即可解决

posted @ 2018-12-10 22:24  香吧香  阅读(6940)  评论(0编辑  收藏  举报