【问题标题】:Facing "onMeasure() did not set the measured dimension by calling setMeasuredDimension()" error when using gridview使用gridview时面临“onMeasure()没有通过调用setMeasuredDimension()设置测量尺寸”错误
【发布时间】:2018-11-27 15:23:23
【问题描述】:

我在我的应用程序中使用了 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() 设置测量尺寸标签(174)

这里是代码sn-p

<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>

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

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

谢谢

【问题讨论】:

  • 是 iOS / Android 的问题吗?
  • 是iOS的,我还没查过android

标签: nativescript nativescript-angular


【解决方案1】:

与 Angular 一起使用时,它看起来像是带有插件的 known issue

【讨论】:

  • 我不太确定这个问题是否与我的有关,但我找到了问题的原因。我将 tns-core-modules 改回 ^4.2.0 并将 tns-platform-declarations 从 5 改回 ^4.0.0 并且问题已修复。该插件似乎与 tns 的最新更新不兼容
  • 如果您只使用标签,则会出现上述错误。如果您使用其他组件,例如 TextField 或只是 StackLayout 它永远不会被渲染。所以我相信这里的核心问题是一样的。
【解决方案2】:

您似乎没有导入命名空间

添加:xmlns:gv="nativescript-grid-view" 到您的页面声明 然后在 &lt;GridView ...&gt; 前面加上 &lt;gv:GridView ...&gt;

【讨论】:

  • 这是 NativeScript Core 的做事方式,它的 registerElement 带有 Angular。
猜你喜欢
  • 2017-12-23
  • 1970-01-01
  • 2017-04-12
  • 1970-01-01
  • 1970-01-01
  • 2015-11-22
  • 1970-01-01
  • 1970-01-01
  • 2021-08-30
相关资源
最近更新 更多