微信小程序—引入页面/组件include、import
第一种:我在include页面引入import页面
一定要注意include 和 import标签后面的/
<!-- 引入整个import页面 -->
<include src="../import/import.wxml" />

<text>我是被include页面引入的import页面</text>

效果:
第二种:引入import页面中的组件
<import src="../import/import" />
<template is="a" data="{{a: '模版a的内容'}}"/>
// data要在include.wxml里写

<template name="a">
<text>这里是import页面的模版a--{{a}}</text>
</template>
<template name="b">
<text>这里是import页面的模版b</text>
</template>

效果:

本文详细介绍了微信小程序中使用include和import标签引入页面和组件的方法。通过实例展示了如何在include页面中完整引入import页面,以及如何仅引入import页面中的特定组件。文章提供了代码示例,帮助开发者更好地理解和应用。
503

被折叠的 条评论
为什么被折叠?



