微信小程序开发笔记

最近几天在做微信小程序方面的研究,记录一下过程的点滴。

给data里的内容赋值

在onLoad方法为data中定义的变量赋值,直接使用=号是不起作用的。需要使用setData方法

this.setData({
      activities: api.getActivities("11", function (data) {
        console.log("getActivities" + data);
      })
    })    

创建底部或顶部标题栏

app.json的内容如下,tabBar就是定义标题栏的内容

{
  "pages": [
    "pages/index/index",
    "pages/logs/logs",
    "pages/create/create",
    "pages/list/list"
  ],
  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "约啊",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "selectedColor": "#1296db",
    "list": [
      {
        "pagePath": "pages/index/index",
        "iconPath":"static/images/home.png",
        "selectedIconPath": "static/images/home.png",
        "text": "首页"
      },
      {
        "pagePath": "pages/list/list",
        "iconPath": "static/images/home.png",
        "selectedIconPath": "static/images/home.png",
        "text": "活动"
      },
      {
        "pagePath": "pages/list/list",
        "iconPath": "static/images/home.png",
        "selectedIconPath": "static/images/home.png",
        "text": "活动1"
      },
      {
        "pagePath": "pages/logs/logs",
        "iconPath": "static/images/home.png",
        "selectedIconPath": "static/images/home.png",
        "text": "我"
      }
    ]
  }
}

标题栏的链接必须有pages里面定义的值,否则不显示标题栏。

"pages": [
    "pages/index/index",
    "pages/logs/logs",
    "pages/create/create",
    "pages/list/list"
  ],

你可能感兴趣的:(微信小程序开发笔记)