在Nativescript中创建组件的正确方法是什么?

在Nativescript中创建组件的正确方法是什么?,nativescript,Nativescript,在Nativescript中创建自定义模板的正确方法是什么 例如,我有XML结构,如: <FlexboxLayout flexDirection="column" alignItems = "stretch"> <Border borderWidth="1" borderColor="#000000"> <FlexboxLayout height="60"> <Button cssCla

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>

我认为您会发现这些资源非常有用:


我想您会发现这些资源非常有用:


在您的情况下,您可能需要考虑创建自己的UI插件-在您的情况下,您可能需要考虑创建自己的UI插件-
<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>