解决ERROR Error: Cannot find a differ supporting object ‘[object Object]‘
程序员文章站
2022-03-03 18:32:30
...
前提:最近新增一个标签html页面新增如下代码:
<ng-container *ngFor="let item of this.secondLevelModalData">
<li class="publish-li" (click)="publishClick(item)">
<div class="publish-li-clicle">
<img class="li-img" src="{{item.icon}}"
onerror="this.src='assets/laijian/[email protected]'" />
</div>
<p class="li-p">{{item.label}}</p>
</li>
</ng-container>
结果页面报错:
ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.push../node_modules/@angular/common/fesm5/common.js.NgForOf.ngDoCheck (common.js:3368)
at checkAndUpdateDirectiveInline (core.js:22102)
at checkAndUpdateNodeInline (core.js:23363)
at checkAndUpdateNode (core.js:23325)
at debugCheckAndUpdateNode (core.js:23959)
at debugCheckDirectivesFn (core.js:23919)
at Object.eval [as updateDirectives] (SharePageComponent.html:127)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:23911)
at checkAndUpdateView (core.js:23307)
at callViewAction (core.js:23548)
原因是因为当前传入的参数是一个对象,改成数组即可。
像下面这样:
<ng-container *ngFor="let item of this.secondLevelModalData.data">
<li class="publish-li" (click)="publishClick(item)">
<div class="publish-li-clicle">
<img class="li-img" src="{{item.icon}}"
onerror="this.src='assets/laijian/[email protected]'" />
</div>
<p class="li-p">{{item.label}}</p>
</li>
</ng-container>
推荐阅读
-
解决启动MongoDB错误:error while loading shared libraries: libstdc++.so.6:cannot open shared object file:
-
解决error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file
-
error while loading shared libraries: xxx: cannot open shared object file: No such file or directory
-
gmx-MMPBSA — error while loading shared libraries: libgfortran.so.3: cannot open shared object file
-
Cannot get a connection, pool error Timeout waiting for idle object
-
解决Field error in object ‘tbPet‘ on field ‘birthday‘: rejected value [2020-07-30]; codes [typeMismatch.
-
mysql初始化/usr/local/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
-
PHP Fatal error: Cannot use object of type stdClass as array in错误_PHP教程
-
错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory,errorwhileloading_PHP教程
-
最后的分了 。Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';是什么意思解决思路