zoukankan      html  css  js  c++  java
  • 一对一、模拟本地的数据库动态绑定数据(微信小程序)

    核心:使用wx:for="{{posts_key}}",用数组的形式来绑定多个的内容,利用for循环来反复调用后台数据,如果没用用posts_key了,那么对应的item_这种命名就是不可以的!

    Wxml

     <block wx:for="{{posts_key}}" wx:for-item="item" wx:for-index="idx" wx:key="idx">
        <view catchtap="onPostTap" data-postId="{{item.postId}}">
          <image src="{{item.images}}"></image>
          <text>{{item.content}}</text>
        </view>
      </block> 

    JS

    var postsData = require('../../data/skip-data.js')
    const app = getApp()
    Page({
      data: {
      },
      onLoad:function(options){
        this.setData({
          posts_key:postsData.postList
        });
      },
    })
    

      

    Skip-data,js(这个脚本用来模拟本地数据库)

    var local_database = [
      {
        content: "VIPKID 纯北美外教 代言人刘涛",
        images: "/images/dian1@2x.png",
        postId: 0,
      },
      {
        content: "哒哒英语 专属外教 代言人孙俪",
        images: "/images/dian1@2x.png",
        postId: 1,
      },
      {
        content: "51Talk 高校教材 代言人贾乃亮",
        images: "/images/dian1@2x.png",
        postId: 2,
      },
      {
        content: "VipJr 量身定制课 代言人姚明",
        images: "/images/dian1@2x.png",
        postId: 3,
      },
      {
        content: "以上都想试听",
        images: "/images/dian1@2x.png",
        postId: 4,
      },
    ]
    module.exports = {
      postList: local_database
    }
    

      

  • 相关阅读:
    ptrace
    CentOS 5.4 final下Systemtap的安装
    SystemTap 静态探针安装包
    sysdig
    ORACLE 内部原理
    An introduction to KProbes
    CentOS6.5升级手动安装GCC4.8.2 与 CentOS 6.4 编译安装 gcc 4.8.1
    在Oracle Linux上安装dtrace
    dwarf调试信息格式入门
    MySQL 5.6.20-4 and Oracle Linux DTrace
  • 原文地址:https://www.cnblogs.com/EdisonVan/p/9031005.html
Copyright © 2011-2022 走看看