微信小程序template

1.template中只包含wxml和wxss文件,在template下新建文件wxml和wxss

                                                   

2.将template的name属性命名,然后进行页面布局

<template name="lunbo">
<swiper autoplay="true" circular="{{circular}}" indicator-dots="true" indicator-color="rgba(255,255,255, .3)" indicator-active-color="green">
<block wx:for="{{banner}}" wx:key="banner">
<swiper-item>
<image src="{{item.url}}" class="slideImage" mode="widthFix" data-index="{{item.id}}" bindtap='test' />
</swiper-item>
</block>
</swiper>
</template>

3.在文件中通过import导入模板文件,通过is="模板的name”进行区别引用,引入css样式

index.wxml

<!--index.wxml-->
<import src="/template/lunbo/lunbo.wxml" />
<import src="/template/scrollImg/scrollImg.wxml" />
<import src="/template/zheZhao/zheZhao.wxml" />
<view class="container">
<!-- 轮播图 -->
<view>
<template is="lunbo" data="{{banner,circular}}" />
</view>
<!-- 三个logo -->
<view class='logos-style'>
<view wx:for="{{logos}}" wx:key="logos" style='width: 33%;'>
<image src='{{item.url}}' style='width: 44rpx; height: 44rpx;'></image>
<text style='display: block'>{{item.text}}</text>
</view>
</view>
<!-- 走马灯 -->
<view style='margin-top: 20rpx; background-color: #fff'>
<template is="scrollImg" data="{{perorders}}" />
</view>
</view>
<!-- 优惠券遮罩 -->
<view>
<template is="zheZhao" data="{{displaya,animationData}}"></template>
</view>

在index.wxss中引入样式

/**index.wxss**/
@import "/template/lunbo/lunbo.wxss";
@import "/template/scrollImg/scrollImg.wxss";
@import "/template/zheZhao/zheZhao.wxss";

4.template中没有js文件,可在模板中声明js操作,在引用文件中实现js操作


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值