小程序开发--template模板
小程序的template模板可以说是我遇到的最简单的了,看看实例:
<template name="article">
<view class='container'>
<image src="{{post_author}}"></image>
<text>{{post_date}}</text>
</view>
</template>
只需在最外层加个template标签,指定其name就可以在其他地方引用了,现在我另外一个wxml中需要使用这个模板,首先引入这个模板:
<import src="xxxxx.wxml" />
然后就可以进行使用,指定其is属性为我们之前设置的name:
<template is="article" />
啊,还真的是很方便呢。这里填个小坑,关于css外部引用的用法:
@import "xxxx.wxss"
对了,再填一坑,说说路径的引用吧:
/ 根目录 ./ 当前目录 ../ 上一级目录
有点乱呢这篇。

浙公网安备 33010602011771号