Nativescript通过代码添加ScrollView(Javascript) [英] Nativescript Add ScrollView through Code (Javascript)

查看:44
本文介绍了Nativescript通过代码添加ScrollView(Javascript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Javascript与Nativescript结合使用,我正在通过代码而不是XML加载页面.

Using Javascript with Nativescript and I am loading a page through code rather than XML.

我一切正常,但是我想添加一个ScrollView,然后在其中放置一个布局.

I have it all working, however I want to add a ScrollView and then place a layout with in that.

我将如何处理?

我试过了:

var scroll = new ScrollView();
var stackLay = new StackLayout();

stackLay.addChild(stuff);
....


scroll.addChild(stackLay);

但是,出现错误"scroll.addChild不是函数"

However, I get error "scroll.addChild is not a function"

谢谢.

推荐答案

ScrollView 不是布局,而是继承自 ContentView 孩子.

ScrollView is not a layout but inherited from ContentView, therefore you can't add more than one child.

试试

scroll.content = stackLay;

这篇关于Nativescript通过代码添加ScrollView(Javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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