亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法在 Object.eval [as updateDirectives] 中讀取 null

無法在 Object.eval [as updateDirectives] 中讀取 null

慕娘9325324 2021-12-23 15:10:07
我正面臨一個我不清楚的錯誤。我能夠看到要編輯的數據,但每次都會出現這樣的錯誤。我試圖捕捉錯誤,但我沒有弄明白它來自哪里:每個 console.log 都像例外一樣工作。我認為問題在于第一次加載時的數據為空。這只有在我嘗試顯示第二個時才會出現,ngFor因為如果我只讓第一個而不是它工作正常但不顯示arrays of comments the second *ngFor.RROR TypeError: Cannot read property '1' of null    at Object.eval [as updateDirectives] (PostsListComponent.html:20)    at Object.debugUpdateDirectives [as updateDirectives]我正在獲取類似這樣的數據。<tr *ngFor="let post of posts$ | async; trackBy:trackByFunction">    <td class="title">{{post.title}}</td>    <td class="dateTime">{{post.body}}</td>    <div *ngFor="let comment of (groupedComments$ | async)[post.id]; trackBy:trackByFunction">      <div>      <td *ngIf="!isEditable(comment)" class="comment">{{comment.name}}</td>      <textarea class="comment" *ngIf="isEditable(comment)" [(ngModel)]="editableComment.name"></textarea>      <td *ngIf="!isEditable(comment)"class="comment">{{comment?.body}}</td>      <textarea class="comment" *ngIf="isEditable(comment)" [(ngModel)]="editableComment.body"></textarea>      <td class="comment" *ngIf="comment.email === '[email protected]' && comment.body.length < 200">        {{comment.email}}        <button  *ngIf="!isEditable(comment)" (click)="deleteComment(comment.id)" class="btn btn-danger">Delete</button>        <button *ngIf="!isEditable(comment)" (click)="editComment(comment)" class="btn btn-info" style="margin-left: 10px">Edit</button>        <button *ngIf="isEditable(comment)" (click)="update(comment)" class="btn btn-info" style="margin-left: 10px">Update</button>        <button *ngIf="isEditable(comment)" (click)="cancel()" class="btn btn-danger" style="margin-left: 10px">Cancel</button>      </td>      </div>    </div>  </tr>
查看完整描述

1 回答

?
慕桂英546537

TA貢獻1848條經驗 獲得超10個贊

groupedComments$ | asyncnull在收到 http 響應之前,這就是原因。


查看完整回答
反對 回復 2021-12-23
  • 1 回答
  • 0 關注
  • 282 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號