在Nativescript
中创建自定义模板的正确方法是什么?
例如,我有XML
结构,如:
<FlexboxLayout flexDirection="column" alignItems = "stretch">
<Border borderWidth="1" borderColor="#000000">
<FlexboxLayout height="60">
<Button cssClass="sdk-button" col="0" text="initSDK" tap="{{initSdk}}" flexGrow="1"/>
<StackLayout orientation="horizontal" class="data-wrapper" flexGrow="3" paddingLeft="20">
<Label text="{{ initSdkResponse }}" class="data_wrapper-label" textWrap="true"/>
</StackLayout>
</FlexboxLayout>
</Border>
</FlexboxLayout>
我想创建具有上述结构的组件,名为MyItem
并使用如下:
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<StackLayout orientation="vertical">
<MyItem buttonName="click1"
buttonAction="onClick1()"
labelText="xxxxxxx1"
></MyItem>
<MyItem buttonName="click2"
buttonAction="onClick2()"
labelText="xxxxxxx2"
></MyItem>
</StackLayout>
</Page>