随笔分类 - 小程序
摘要:page获取app.js:const app = getApp(); page的js访问全局变量(get/set):const app = getApp(); app.globalData.openid app.js中访问(get/set):this.globalData
阅读全文
摘要:wx.setStorage({ string key, any data, function success, function fail, function complete }) 例如: wx.setStorage({ key:"key", data:"value" }) wx.setStora
阅读全文
摘要:使用标签open-data ,和属性type(wxml) 可在wxml显示用户信息(自己的), 只能显示,但不能获取信息 type: userAvatarUrl(用户头像)、 userNickName(用户昵称)、 userCountry(用户国家)、 userCity(用户城市) 例如: <ope
阅读全文
摘要:传统微信授权登录方式 小程序调用wx.login获取(微信服务器端)code(5分钟有效,5分钟不使用失效,需重新调用wx.login); 小程序调用wx.request 将code传递给后端服务器; 后端使用code换取openid和session_key; 后端将openid(用户标识)发送个小
阅读全文
摘要:小程序的分享功能 <button open-type="share">分享</button> 点击此按钮后会触发(父组件的): //系统自带方法 onShareAppMessage: function (event) { const blog = event.target.dataset.blog;
阅读全文
摘要:const pages = getCurrentPages();//获取当前的页面栈 console.log("pages,", pages) const prevPage = pages[pages.length - 1];//当前的page prevPage.onPullDownRefresh(
阅读全文
摘要:子组件的使用 在.json中配置"usingComponents"字段,{"标签名": "子组件路径"} "usingComponents": { "x-blog-cart": "/components/blog-cart/blog-cart", "x-blog-ctrl": "/component
阅读全文
摘要:页面滚动 使用scroll-view标签包裹内容,可以实现页面滚动 scroll-y="true"纵向可以滚动 scroll-x="true"横向可以滚动 <scroll-view scroll-y="true"> 。。。。 </scroll-view>
阅读全文
摘要:tcb-router 基于koa风格的小程序·云开发云函数轻量级类路由库,主要用于优化服务端函数处理逻辑 安装 在云函数当前目录下安装:npm install --save tcb-router 使用 const tcbRouter = require('tcb-router'); exports.
阅读全文