微信小程序-视图层-引用

2019-03-16  本文已影响0人  叫我王必过

一、引用的注意事项

1、引用的方式

<!-- item.wxml -->
<template name="item">
  <text>{{text}}</text>
</template>
<!-- index.wxml -->
<import src="item.wxml" />
<template is="item" data="{{text: 'forbar'}}" />

import 有作用域的概念,即只会 import 目标文件中定义的 template,而不会 import 目标文件 import 的 template。

<!-- index.wxml -->
<include src="header.wxml" />
<view>body</view>
<include src="footer.wxml" />
上一篇 下一篇

猜你喜欢

热点阅读