6.微信小程序 模板的书写及调用 微信小程序

shuke 2017-11-28 1495

 WXML提供模板:

一种是调用,一种是模块.

 模版分为两种:


一种是调用:

 调用使用 include 可以将目标文件除了 <template/> <wxs/> 外的整个代码引入,相当于是拷贝到 include 位置

<include src="header.wxml"/>

一种是模块

 模块使用 import 可以在该文件中使用目标文件定义的template,如:

import.wxml:

 <template name="item">

  <text>{{text}}</text>

</template>

index.wxml:

<import src="item.wxml"/>

<template is="item" data="{{text: 'forbar'}}"/>


最新回复 (0)
全部楼主
返回