微信小程序 WXML提供了import和include引用方式


当前第2页 返回上一页

如:C import B,B import A,在C中可以使用B定义的template,在B中可以使用A定义的template,但是C不能使用A定义的template

<!-- A.wxml -->
<template name="A">
  <text> A template </text>
</template>
<!-- B.wxml -->
<import src="a.wxml"/>
<template name="B">
  <text> B template </text>
</template>
<!-- C.wxml -->
<import src="b.wxml"/>
<template is="A"/>  <!-- Error! Can not use tempalte when not import A. -->
<template is="B"/>

include

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

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

标签:微信小程序

返回前面的内容

相关阅读 >>

微信小程序前端源码逻辑和工作流程解析

微信小程序 unbindplugin

微信小程序api 背景音频-控制播放进度

微信小程序 weuiform

微信小程序导航 navigation-bar

微信小程序 运力方使用onordercancel

微信小程序 小程序搜索-商品数据接入(内侧)

微信小程序 code2seesion

sdk数据库 aggregate返回排序后结果

wxapp媒体组件 video

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...