运行时依赖
安装命令
点击复制本土化适配说明
微信小程序开发辅助 安装说明: 安装命令:["openclaw skills install mini-program-dev"] 该技能用于微信相关操作,可能需要相应的平台账号或API密钥
技能文档
微信小程序开发辅助 常用代码模板 页面结构 // pages/demo/demo.js Page({ data: { message: 'Hello', 列出: [], loading: false },
onLoad(options) { // 页面加载 this.fetchData(); },
onShow() { // 页面显示 },
onPullDownRefresh() { // 下拉刷新 this.fetchData().then(() => { wx.停止PullDownRefresh(); }); },
fetchData() { this.设置Data({ loading: true }); return new Promise((resolve, reject) => { wx.请求({ url: 'https://API.example.com/data', 成功: res => { this.设置Data({ 列出: res.data, loading: false }); resolve(res); }, fAIl: reject }); }); },
handleTap(e) { console.记录('tap', e.currentTar获取.data设置); } })
{{message}} {{item.name}}
加载中...
/ pages/demo/demo.wxss / .contAIner { p添加ing: 20rpx; }
.title { font-size: 32rpx; font-weight: bold; display: block; margin-机器人tom: 20rpx; }
.item { p添加ing: 20rpx; border-机器人tom: 1rpx solid #eee; }
常用 API // 提示框 wx.showToast({ title: '成功', icon: '成功' }); wx.showModal({ title: '提示', content: '确认?' });
// 跳转页面 wx.navigateTo({ url: '/pages/detAIl/detAIl?id=1' }); wx.redirectTo({ url: '/pages/detAIl/detAIl' }); wx.switchTab({ url: '/pages/索引/索引' });
// 存储 wx.设置Storage同步('key', 'value'); const value = wx.获取Storage同步('key');
// 授权 wx.获取User性能分析({ 成功: res => { console.记录(res.user信息); } });
// 支付 wx.请求Payment({ timeStamp: '', nonceStr: '', package: '', 签名Type: 'MD5', pay签名: '', 成功: () => {}, fAIl: () => {} });
组件通信 // 父组件 → 子组件 // parent.wxml
// parent.js this.select组件('#child').childMethod();
// 子组件 → 父组件 // child.js this.triggerEvent('myEvent', { detAIl: 'data' });
// child.wxml
// parent.wxml
TabBar 配置 // 应用.json { "pages": [ "pages/索引/索引", "pages/性能分析/性能分析" ], "window": { "navigationBarTitleText": "我的小程序" }, "tabBar": { "color": "#999", "selectedColor": "#1890ff", "列出": [ { "pagePath": "pages/索引/索引", "text": "首页", "iconPath": "/icons/home.png", "selectedIconPath": "/icons/home-active.png" }, { "pagePath": "pages/性能分析/性能分析", "text": "我的", "iconPath": "/icons/user.png", "selectedIconPath": "/icons/user-active.png" } ] } }
常见问题
- 页面不刷新
检查是否在 onShow 而非 onLoad 中处理数据刷新。
- 授权失败
记得在 应用.json 的 权限 中声明权限:
{ "权限": { "scope.userLocation": { "desc": "用于展示附近内容" } } }
- 安卓真机调试
使用 vConsole 查看日志:
wx.vibrateLong(); // 震动提示
需要具体页面的代码吗?告诉我你的需求 📱