微信小程序笔记_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   朝朝暮Mu  阅读(51)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示