背后的本机代码-动态地将GridLayout添加到ScrollView [英] Nativescript Code Behind - Add GridLayout to ScrollView Dynamically

查看:76
本文介绍了背后的本机代码-动态地将GridLayout添加到ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照该页面上的示例在Nativescript中创建动态GridLayout:

I am creating a dynamic GridLayout in Nativescript following the example on there page:

https://docs.nativescript.org/ui/layouts/layout-containers

它允许我使用JavaScript制作GridLayout,因为我需要它是动态的.

It allows my to make a GridLayout using javascript, as I need it to be dynamic.

但是,我想将此布局放在ScrollView中.

However, I want to put this layout in a ScrollView.

我相信我打算做这样的事情

I believe I'm meant to do something like this

const grid = new GridLayout();
const scroll = new ScrollView();  
grid.addChild();

...

scroll.addView(grid);

我经常收到错误消息,说"addView"不是一个函数.

I constantly get an error saying "addView" is not a function.

这是正确的方法吗?什么是'require(");'我需要ScrollView吗?

Is this the correct method? What 'require("");' do I need for the ScrollView?

谢谢

推荐答案

您需要从 import { ScrollView } from 'ui/scroll-view';

,它不是addView,可用的公共方法是 _addView

and it's not addView, available public method is _addView

这篇关于背后的本机代码-动态地将GridLayout添加到ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆