首页 > 解决方案 > 使用gridview时遇到“onMeasure()没有通过调用setMeasuredDimension()设置测量尺寸”错误

问题描述

我在我的应用程序中使用 gridview 插件。(https://market.nativescript.org/plugins/nativescript-grid-view

在我的参考文献中添加以下行后,我遇到了一个错误:

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

错误:

file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:58:124: JS ERROR 错误: onMeasure() 没有通过调用 setMeasuredDimension() Label(174) 设置测量尺寸)

这是代码片段

<GridLayout class="page">
	<GridView [items]="watches" colWidth="49%" rowHeight="280">
	  <ng-template let-item="item">
		<FlexboxLayout class="watch-item">
		  <Label text="Hi"></Label>
		</FlexboxLayout>
	  </ng-template>
	</GridView>
 </GridLayout>

我尝试了不同的布局,但错误是一样的。

我想知道如何解决这个问题?

谢谢

标签: nativescriptnativescript-angular

解决方案


与 Angular 一起使用时,插件似乎是一个已知问题。


推荐阅读