navbar.js 799 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const app = getApp()
  2. Component({
  3. properties: {
  4. navbarData: { //navbarData 由父页面传递的数据,变量名字自命名
  5. type: Object,
  6. value: {},
  7. observer: function (newVal, oldVal) {}
  8. }
  9. },
  10. data: {
  11. height: '',
  12. //默认值 默认显示左上角
  13. navbarData: {
  14. showCapsule: 1
  15. }
  16. },
  17. attached: function () {
  18. // 获取是否是通过分享进入的小程序
  19. this.setData({
  20. share: app.globalData.share
  21. })
  22. // 定义导航栏的高度 方便对齐
  23. this.setData({
  24. height: app.globalData.height
  25. })
  26. },
  27. methods: {
  28. // 返回上一页面
  29. _navback() {
  30. wx.navigateBack()
  31. },
  32. //返回到首页
  33. _backhome() {
  34. wx.switchTab({
  35. url: '/pages/index/index',
  36. })
  37. }
  38. }
  39. })