美文网首页
WXML 模板引用2 Demo

WXML 模板引用2 Demo

作者: CPU_Easy | 来源:发表于2018-10-28 14:54 被阅读0次

import引入:

不支持多层嵌套引入,只支持一次引用,以防止死循环的产生

<!-- a.wxml -->
<view>Hello World</view>
<template name="a">
  Hello World!
</template>
<!-- helloworld.wxml -->
<import src="a.wxml"></import>
<template is="a"></template>

is 表示引入name为"a"的代码块

运行结果: image.png

include引入

将目标文件内除了模板代码块(<template>)外的所有代码引入

<!-- helloworld.wxml -->
<include src="a.wxml"/>
<template is="a"></template>

<!-- a.wxml -->
<template name="a">
  <view>
    This is a.wxml.
  </view>
</template>
<view>Hello World</view>

运行结果: 输入图片说明

相关文章

网友评论

      本文标题:WXML 模板引用2 Demo

      本文链接:https://www.haomeiwen.com/subject/mmgptqtx.html