footer/footer.vue

  1. <template>
  2. <footer class="ion-footer" :class="[modeClass,{'hide-bar':isHide}]" :style="style">
  3. <slot></slot>
  4. </footer>
  5. </template>
  6. <script type="text/javascript">
  7. /**
  8. * @component Footer
  9. * @description
  10. *
  11. * ## 基础组件 / Footer组件
  12. *
  13. * Header和Footer组件结构类似, 都是提供一个包裹容器, 不同的是一个固定在上面, 一个固定在下面.
  14. *
  15. * Header组件是Vimo页面的的三个主要构成之一, 主要是为Toolbar/Navbar/自定义结构提供一个容器,
  16. * 该组件将始终固定在页面顶部, Content组件会根据Header的高度自动设定`margin`值, 或者`padding`值.
  17. *
  18. * ### 可用的样式属性
  19. * - [no-border] - 无边框
  20. *
  21. * @demo #/content
  22. *
  23. * */
  24. export default {
  25. name: 'Footer',
  26. inject: {
  27. pageComponent: {
  28. from: 'pageComponent',
  29. default: null
  30. }
  31. },
  32. provide () {
  33. let _this = this
  34. return {
  35. footerComponent: _this
  36. }
  37. },
  38. props: {
  39. mode: {
  40. type: String,
  41. default () {
  42. return (this.$config && this.$config.get('mode', 'ios')) || 'ios'
  43. }
  44. }
  45. },
  46. data () {
  47. return {
  48. // -------- public --------
  49. isHide: false,
  50. style: {}
  51. }
  52. },
  53. computed: {
  54. modeClass () {
  55. return `footer-${this.mode}`
  56. }
  57. },
  58. methods: {
  59. // -------- public --------
  60. /**
  61. * @function hide
  62. * @description
  63. * 隐藏Footer
  64. * */
  65. hide () {
  66. this.isHide = true
  67. },
  68. /**
  69. * @function show
  70. * @description
  71. * 显示Footer
  72. * */
  73. show () {
  74. this.isHide = false
  75. },
  76. /**
  77. * @function toggle
  78. * @description
  79. * Toggle显示Footer
  80. * */
  81. toggle () {
  82. this.isHide = !this.isHide
  83. },
  84. /**
  85. * @function setStyle
  86. * @param {object} style - 传入的样式对象
  87. * @see https://cn.vuejs.org/v2/guide/class-and-style.html#对象语法-1
  88. * @description
  89. * 设置Footer的样式
  90. * */
  91. setStyle (style) {
  92. this.style = style
  93. }
  94. },
  95. created () {
  96. if (this.pageComponent) {
  97. this.pageComponent.footerComponent = this
  98. }
  99. this.$root.$on('onMenuOpen', () => {
  100. this.hide()
  101. })
  102. this.$root.$on('onMenuClosing', () => {
  103. this.show()
  104. })
  105. this.$root.$emit('footer:created', this)
  106. },
  107. mounted () {
  108. this.$root.$emit('footer:mounted', this)
  109. }
  110. }
  111. </script>