【发布时间】:2018-09-12 21:19:53
【问题描述】:
我想添加另一个组件,例如布局、按钮、图像等...
这是我的 xml 代码,我想在 ID 为“chatbox”的 stacklayout 上添加 xml:
<GridLayout orientation="vertical" rows="*, auto" columns="auto,*, auto">
<ScrollView row="0" colSpan="3" col="0">
<StackLayout id="chatbox">
// I want to add XML component here dynamically
</StackLayout>
</ScrollView>
这是我当前的打字稿代码,但它不起作用。它甚至不显示编译错误。
export function onSendButtonTap(args: EventData){
const button = <Button>args.object;
const bindingContext = <HomeViewModel>button.bindingContext;
const page = <Page>args.object;
const stack = new StackLayout();
stack.getViewById("chatbox");
const label = new Label();
label.text = "label";
stack.addChild(label);;
bindingContext.sendMessage(); }
【问题讨论】:
标签: xml typescript nativescript