5-3章节template无法实现,不知道错在哪里了。

来源:

我们刘长瑞

2016-12-19

代码1:posts.wxml

<import src="post-item/post-item-template.wxml" />

<view>

    <swiper autoplay="auto" indicator-dots="true" interval="5000">

    <swiper-item><image src="/images/post/xiaolong.jpg"></image></swiper-item>

    <swiper-item><image src="/images/post/bl.png"></image></swiper-item>

    <swiper-item><image src="/images/post/vr.png"></image></swiper-item>

</swiper>

<block wx:for="{{postList}}" wx:for-item="{{item}}" wx:fot-index="idx">

    <template is="postItem" data="{{item}}" />

</block>

</view>

代码2:post-item-template.wxml

<template name="postItem">

    <view class="post-container">

        <view class="post-author-date">

            <image class="post-author" src="{{item.avatar}}"></image>

            <text class="post-date">{{item.date}}</text>

        </view>

        <text class="post-title">{{item.title}}</text>

        <image class="post-image" src="{{item.imgSrc}}"></image>

        <text class="post-content">{{item.content}}</text>

        <view class="post-like">

            <image class="post-like-image" src="/images/icon/view.png"></image>

            <text class="post-like-font">{{item.collection}}</text>

            <image class="post-like-image" src="/images/icon/chat.png"></image>

            <text class="post-like-font">{{item.reading}}</text>

        </view>

    </view>

</template>

http://szimg.mukewang.com/585776c70001e16613660726.jpg

写回答

2回答

7七月

2016-12-19

出现模板无法显示,又没有任何错误,请从两个方面找原因。第一,模板的路径对不对。第二,数据绑定的变量是不是取值的时候不对。基本上是这两个问题。

0
0

慕粉2117253696

2017-01-07

遇到了同样的问题

0
1
7七月
你的问题可能是this.data数据绑定失效,请参考知乎
2017-01-07
共1条回复

微信小程序入门与实战(全新版) 超20000人学习的好课

4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!

23960 学习 · 6930 问题

查看课程