搜索
您的当前位置:首页正文

微信小程序-template模板使用

来源:二三娱乐

声明模板:

<template name='section_header'>
  <view class='kg-section-header'>
    <view style='width:10rpx; height:33rpx;background-color:#f9aa76; margin-left:20rpx'></view>
    <view class='kg-text-normal-gray' style='margin-left:16rpx'>{{title}}</view>
  </view>
</template>

使用:
1、导入<import src='/template/index.wxml'></import>
2、使用
<template is="section_header" data="{{title:'2018-09-12'}}"></template>

效果:


image.png

说明:
title就是传入的值。点击事件的传递和正常写的点击事件一样。比如在template里面bindtap一个点击事件,在使用这个template的页面的js文件里面实现这个点击事件即可。

Top