微信小程序template与component的使用方法

    技术2023-07-20  81

    1.template的使用方法

    a页面引用b页面的模板

    b页面的代码

    <template name="a"> <view>AAAAAAAA</view> </template> <template name="b"> <view> BBBBBBBBBB </view> </template> <template name="c"> <view> CCCCCCC </view> </template>

    a页面的代码如下

    <import src="../b_template/index.wxml"/> <template is="a" /> <template is="b" /> <template is="c" />

    2.  component

    目录结构

    在下面的index中引用component文件下的模板

    引用页

    josn

    "usingComponents": { "today":"/component/home/today/index" }

    wxml

    <!-- 特价 --> <today today="{{list_arr.goodsList}}" />

     

    Processed: 0.014, SQL: 9