微信小程序笔记_01

微信小程序学习笔记之入门指南

1.设置小程序tabBar

  "tabBar": {
    "color": "#B2B8D2",
    "selectedColor": "#536DFE",
    "borderStyle": "black",
    "backgroundColor": "#ffffff",
    "list": [
      {
        "text": "首页",
        "pagePath": "pages/home/home",
        "iconPath": "images/tabbar/home.png",
        "selectedIconPath": "images/tabbar/home1.png"
      },
      {
        "text": "文章",
        "pagePath": "pages/article/article",
        "iconPath": "images/tabbar/article.png",
        "selectedIconPath": "images/tabbar/article1.png"
      },
      {
        "text": "排行榜",
        "pagePath": "pages/ranking/ranking",
        "iconPath": "images/tabbar/ranking.png",
        "selectedIconPath": "images/tabbar/ranking1.png"
      },
      {
        "text": "我的",
        "pagePath": "pages/mine/mine",
        "iconPath": "images/tabbar/mine.png",
        "selectedIconPath": "images/tabbar/mine1.png"
      }
    ]
  }

2.常用的API和组件

序号 API/组件 功能 链接
1 wx.getSystemInfo(Object object) 获取系统信息 https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfo.html
2 wx.getStorageSync(string key) 从本地缓存中同步获取指定 key 的内容 https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.getStorageSync.html
3 wx.setStorageSync(string key, any data) 将数据存储在本地缓存中指定的 key 中 https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html
4 wx.login(Object object) 调用接口获取登录凭证(code) https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html
5 wx.getSetting(Object object) 获取用户的当前设置 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.getSetting.html
6 wx.getUserInfo(Object object) 获取用户信息 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html
7 ad Banner 广告 https://developers.weixin.qq.com/miniprogram/dev/component/ad.html

3.设置全局变量

//设置全局变量时要在app.js中设置globalData属性,否子会提示错误
globalData:{
        userInfo:null,
        lib_id:"",
    }

4.js中逻辑运算符||和&&的使用方法

4.1、JS中的||符号:

运算方法:

 只要“||”前面为false,不管“||”后面是true还是false,都返回“||”后面的值。

 只要“||”前面为true,不管“||”后面是true还是false,都返回“||”前面的值。

总结:真前假后

4.2、JS中的&&符号:

运算方法:

 只要“&&”前面是false,无论“&&”后面是true还是false,结果都将返“&&”前面的值;

 只要“&&”前面是true,无论“&&”后面是true还是false,结果都将返“&&”后面的值;

总结:假前真后
参考:https://www.cnblogs.com/yuanxinghuo/p/7881366.html

5.js中unshift用法

unshift() 方法可向数组的开头添加一个或更多元素,并返回新的长度。

posted on 2022-03-19 15:37  朝朝暮Mu  阅读(63)  评论(0)    收藏  举报