【问题标题】:NativeScript RadListView component templateNativeScript RadListView 组件模板
【发布时间】:2018-12-10 19:34:00
【问题描述】:

我正在尝试使用 Angular 组件作为 RadListView 的模板。

<StackLayout>
  <RadListView [items]="stories"
               marginRight="-2"
               separatorColor="transparent"
               height="100%">
    <ng-template tkListItemTemplate
                 let-story="item">
      <NewsItem [story]="story"></NewsItem>
    </ng-template>
  </RadListView>
</StackLayout>

我收到以下错误。

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

【问题讨论】:

  • 也许你的NewsItem 没有扩展CustomLayoutView。最简单的答案是在您的内容周围加上&lt;StackLayout&gt;&lt;/StackLayout&gt;
  • hmm 我在NewsItem 的内容周围有一个StackLayout
  • 那不一样。

标签: ios nativescript nativescript-angular ios11.4


【解决方案1】:

想通了。模板本身必须有一个容器。

<StackLayout>
  <RadListView [items]="stories"
               marginRight="-2"
               separatorColor="transparent"
               height="100%">
    <ng-template tkListItemTemplate
                 let-story="item">
      <StackLayout>
        <NewsItem [story]="story"></NewsItem>
      </StackLayout>
    </ng-template>
  </RadListView>
</StackLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-10
    • 2017-09-09
    • 1970-01-01
    相关资源
    最近更新 更多