Nativescript Add ScrollView through Code (Javascript)

若如初见. 提交于 2021-01-29 08:50:36

问题


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

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

How would I go about this?

I have tried:

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

stackLay.addChild(stuff);
....


scroll.addChild(stackLay);

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

Thanks.


回答1:


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

Try

scroll.content = stackLay;


来源:https://stackoverflow.com/questions/52749994/nativescript-add-scrollview-through-code-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!