auth.code2Session来获取openid,openid是微信用户的唯一标识
云开发小程序, 注入广告, 副业的好方式, 边际效益高
openInspect()//查看渲染层/逻辑层
开发前注意:
style 接收动态的样式,在运行时会进行解析,请尽量避免将静态的样式写进 style 中,以免影响渲染速度
开启页面渲染缓存,让显示更快,配置加入 "initialRenderingCache": "static"
接口请求不了,更改APPID试试
getApp(); //.globalData
生命周期
Load
Show
Ready
Hide
UnLoad
组件生命周期
created attached detached
页面间共享数据:
// my-behavior.js
module.exports = Behavior({ data: { sharedText: 'ffff' }, methods: {} })
Page({
behaviors:require('./my-behavior.js'), //可以this.data.sharedText拿到
})
页面可以引用 behaviors 。 behaviors 可以用来让多个页面有相同的数据字段和方法。
页面里部分js代码:
<!--wxml-->
<wxs module="m1">
var msg = "aaa";
var getMax = function(arg1) {}
module.exports.message = msg;
module.exports.getMax = getMax;
</wxs>
<view> {{m1.message}}{{m1.getMax(array)}}</view>
双向绑定语法:
<input model:value="{{value}}" />
获取界面上的节点信息
const query = wx.createSelectorQuery()
query.select('#the-id').boundingClientRect(function(res){res.top // #the-id 节点的上边界坐标(相对于显示区域)})
query.selectViewport().scrollOffset(function(res){res.scrollTop // 显示区域的竖直滚动位置})
query.exec()
不同尺寸屏幕样式不同:
@media (min-width: 480px) { /* 仅在 480px 或更宽的屏幕上生效的样式规则 */ .my-class { width: 200px; } }
【小程序】
最新推荐文章于 2024-07-25 18:18:28 发布