收藏
回答

template模板无法获取{{}}绑定数据显示在页面上,后台也没有报错。

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 工具 6.7.3 2.4.2

- 当前 Bug 的表现(可附上截图)


template模板部分




页面调用模板部分


JS部分


数据部分。


- 预期表现


页面显示信息


- 实际情况


模板中{{}}的数据均无法显示

后台也没有报错信息。

- 复现路径


- 提供一个最简复现 Demo

posts.wxml

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

<view>

<swiper vertical='{{false}}' indicator-dots="true" autoplay="true" interval='3000'>

<swiper-item>

<image src="/images/avatar.jpg"></image>

</swiper-item>

<swiper-item>

<image src="/images/avatar.jpg"></image>

</swiper-item>

<swiper-item>

<image src="/images/avatar.jpg"></image>

</swiper-item>

</swiper>


<block wx:for="{{key}}" wx:for-item="itme" wx:for-index="idx">

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

</block>

</view>


post-itme-template.wxml


<template name="postItem">

<view class="post-container">

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

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

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

</view>

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

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

<text class="post-content">{{content}}

</text>

<view class="post-like">

<image class="post-like-image"

src="/images/avatar.jpg"></image>

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


<image class="post-like-image"

src="/images/avatar.jpg"></image>

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

</view>

</view>

</template>


posts.js


var postsDate = require("../../data/posts-data.js");


Page({


/**

  * 页面的初始数据

  */

data: {

},


/**

  * 生命周期函数--监听页面加载

  */

onLoad: function (options) {

// this.data.postList = postsData.postList

this.setData({

key: postsDate.postList

});

},

})



posts-data.js


var local_database = [

{

date: "Sep 18 2016",

title: "正是霞飞卸妆时",

imgSrc: "/images/avatar.jpg",

avatar: "/images/avatar.jpg",

img_condition: true,

content: "每一个小程序页面也可以使用.json文件来对本页面的窗口表现进行配置。页面的配置只能设置 app.json.中部分 window ",

reading: "112",

collection: "96",

},

{

date: "Sep 3 2056",

title: "正萨科技等你",

imgSrc: "/images/avatar1.jpg",

avatar: "/images/avatar1.jpg",

img_condition: true,

content: "每一个小程序页面也可以使用.json文件来对本页面的窗口表",

reading: "563",

collection: "16",

},

{

title: "微信小程序开发安装工具指南",

content: "每一个小程序页面也可以使用.json文件来对本页面的窗口表",

imgSrc: "/images/avatar1.jpg",

reading: "563",

collection: "16",

date:"Nov 20 2016",

avatar: "/images/avatar1.jpg",

img_condition: true,

}

]


module.exports = {

postList: local_database

}




如有能帮解决的大神请附上支付宝账号 小弟不胜感激

回答关注问题邀请回答
收藏

3 个回答

  • 2018-12-19

    已经得到解决了,谢谢大家。

    2018-12-19
    有用
    回复 1
    • Devil
      Devil
      2019-03-25

      怎么解决的?能否告知一下?

      2019-03-25
      回复
  • 灵芝
    灵芝
    2018-12-18

    麻烦提供代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2018-12-18
    有用
    回复
  • 这都申请了
    这都申请了
    2018-12-18

    代码太长,建议发代码片段,这样有人帮你看的概率比较大

    2018-12-18
    有用
    回复
登录 后发表内容