Nativescript 如何使用removechild()删除xml元素?
有没有关于如何使用removechild()的示例,因为我需要通过代码删除某些xml元素 我知道我可以使用visible属性,但我想完全删除元素您必须在父布局上使用方法。假设您有一个Nativescript 如何使用removechild()删除xml元素?,nativescript,Nativescript,有没有关于如何使用removechild()的示例,因为我需要通过代码删除某些xml元素 我知道我可以使用visible属性,但我想完全删除元素您必须在父布局上使用方法。假设您有一个StackLayout,并希望在单击后删除内部的按钮 XML <StackLayout id="parentLyt"> <Button text="Remove me" tap="onButtonTap"></Button> </StackLayout> exp
StackLayout
,并希望在单击后删除内部的按钮
XML
<StackLayout id="parentLyt">
<Button text="Remove me" tap="onButtonTap"></Button>
</StackLayout>
exports.onButtonTap = function(args) {
var button = args.object;
var page = button.page;
page.getViewById('parentLyt').removeChild(button);
};