- 点击返回或者首页按钮没触发事件
- 点击返回或者首页按钮 需要 触发事件
- 附上代码
< cover-view class = 'head-wrap' > < cover-view class = 'relative' > < cover-view class = 'capsule' wx:if = "{{showBack}}" > < cover-image class = 'back' src = '返回图片' bindtap = 'goback' /> < cover-view class = 'line' ></ cover-view > < cover-image class = 'home' src = '首页图片' bindtap = 'navigateToMiniProgram' /> </ cover-view > < cover-view class = 'capsule-only-home' wx:if = "{{onlyHome}}" > < cover-image class = 'home' src = '首页图片' bindtap = 'navigateToMiniProgram' /> </ cover-view > < cover-view class = 'title' > {{headerTitle}} </ cover-view > </ cover-view > </ cover-view > |
// components/header.js Component({ /** * 组件的属性列表 */ properties: { headerTitle:{ type:String, value: '诸葛找房查房价' } }, /** * 组件的初始数据 */ data: { showBack: false , onlyHome: false }, /** * 组件的方法列表 */ methods: { goback(){ wx.navigateBack({}) }, navigateToMiniProgram(){ wx.navigateToMiniProgram({ appId: 'wxb748bbed6783eafc' , path: 'pages/home/index' , extraData: { foo: 'bar' }, envVersion: 'develop' , success(res) { // 打开成功 }, fail(e){ console.log(e, '打开失败' ) } }) } }, attached() { const pages = getCurrentPages(); this .setData({ showBack:wx.R.length(pages) > 1, onlyHome: wx.R.length(pages) == 1, }) }, }) |
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)