在真机上自定义导航栏点击事件不触发
-
点击返回或者首页按钮没触发事件
-
点击返回或者首页按钮 需要 触发事件
-
附上代码
<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.jsComponent({ /** * 组件的属性列表 */ 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, }) },}) |
