68 lines
1.1 KiB
JavaScript
68 lines
1.1 KiB
JavaScript
// components/navBar.js
|
|
Component({
|
|
options:{
|
|
multipleSlots:true
|
|
},
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties:{
|
|
back:{
|
|
type:Boolean,
|
|
value:false
|
|
},
|
|
backTitle:{
|
|
type:String,
|
|
value:''
|
|
},
|
|
background:{
|
|
type:String,
|
|
value:''
|
|
},
|
|
homeUrl:String
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
statusBarHeight:0,
|
|
navBarHeight:44,
|
|
canBack:true
|
|
},
|
|
lifetimes:{
|
|
attached(){
|
|
const windowInfo = wx.getWindowInfo();
|
|
this.setData({
|
|
statusBarHeight:windowInfo.statusBarHeight
|
|
});
|
|
const pages = getCurrentPages();
|
|
if(pages.length>1){
|
|
this.setData({
|
|
canBack:true
|
|
})
|
|
}else{
|
|
this.setData({
|
|
canBack:false
|
|
})
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
back(){
|
|
wx.navigateBack();
|
|
},
|
|
backHome(){
|
|
wx.reLaunch({
|
|
url: this.properties.homeUrl,
|
|
})
|
|
},
|
|
getHeight(){
|
|
return this.data.statusBarHeight + this.data.navBarHeight;
|
|
}
|
|
}
|
|
}) |