WXML 模板引用2 Demo

2018-10-28  本文已影响0人  CPU_Easy

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>

运行结果: 输入图片说明
上一篇 下一篇

猜你喜欢

热点阅读