1.模板文件的地址\pages\public\public.wxml
2.模板文件的代码
<template name="staffName">
<view>
FirstName
</view>
</template>
3.引入模板文件和使用
<!--index.wxml-->
<!--引入模板文件-->
<import src="../public/public.wxml" />
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto" bindtap="shop">{{text}}</text>
</view>
<!--使用模板文件-->
<template is="staffName" data="{{...staffA}}"></template>
<template is="staffName" data="{{...staffB}}"></template>
<template is="staffName" data="{{...staffC}}"></template>
</view>
<import src="../public/public.wxml" />