ActionBar 操作栏

Scan me!

汇集若干文案或操作按钮的吸底边栏,可用于展示表单信息与提交按钮

引入

  1. import { ActionBar } from 'mand-mobile'
  2. Vue.component(ActionBar.name, ActionBar)

使用指南

默认使用position: fixed固定在页面底部,为避免遮挡内容区底部预留不小于100px的空白(iPhone还需额外增加constant(safe-area-inset-bottom)

代码演示

基本

ActionBar 操作栏 - 图2

  1. <template>
  2. <div class="md-example-child md-example-child-action-bar md-example-child-0">
  3. <md-action-bar :actions="data"></md-action-bar>
  4. </div>
  5. </template>
  6. <script>
  7. import {ActionBar, Toast} from 'mand-mobile'
  8. export default {
  9. name: 'action-bar-demo',
  10. components: {
  11. [ActionBar.name]: ActionBar,
  12. },
  13. data() {
  14. return {
  15. data: [
  16. {
  17. text: '主要按钮',
  18. onClick: this.handleClick,
  19. },
  20. ],
  21. }
  22. },
  23. methods: {
  24. handleClick() {
  25. Toast.succeed('Click')
  26. },
  27. },
  28. }
  29. </script>
  30.  

按钮禁用

ActionBar 操作栏 - 图3

        <template>
  <div class="md-example-child md-example-child-action-bar md-example-child-1">
    <md-action-bar :actions="data"></md-action-bar>
  </div>
</template>

<script>
import {ActionBar, Toast} from 'mand-mobile'

export default {
  name: 'action-bar-demo',
  components: {
    [ActionBar.name]: ActionBar,
  },
  data() {
    return {
      data: [
        {
          text: '次要按钮',
          disabled: true,
        },
        {
          text: '主要按钮',
          disabled: true,
        },
      ],
    }
  },
  methods: {
    handleClick() {
      Toast.succeed('Click')
    },
  },
}

</script>

      

多按钮

ActionBar 操作栏 - 图4

        <template>
  <div class="md-example-child md-example-child-action-bar md-example-child-0">
    <md-action-bar :actions="data"></md-action-bar>
  </div>
</template>

<script>
import {ActionBar, Toast} from 'mand-mobile'

export default {
  name: 'action-bar-demo',
  components: {
    [ActionBar.name]: ActionBar,
  },
  data() {
    return {
      data: [
        {
          text: '次要按钮',
          onClick: this.handleClick,
        },
        {
          text: '主要按钮',
          onClick: this.handleClick,
        },
      ],
    }
  },
  methods: {
    handleClick() {
      Toast.succeed('Click')
    },
  },
}

</script>

      

使用插槽

ActionBar 操作栏 - 图5

        <template>
  <div class="md-example-child md-example-child-action-bar md-example-child-3">
    <md-action-bar :actions="data" @click="onBtnClick">
      <span class="price">
        &yen;128.00<small>起</small>
      </span>
    </md-action-bar>
  </div>
</template>

<script>
import {ActionBar, Dialog} from 'mand-mobile'

export default {
  name: 'action-bar-demo',
  components: {
    [ActionBar.name]: ActionBar,
  },
  data() {
    return {
      data: [
        {
          text: '主要按钮',
        },
      ],
    }
  },
  methods: {
    onBtnClick(event, action) {
      Dialog.alert({
        content: `${action.text}点击`,
      })
    },
  },
}

</script>

<style lang="stylus" scoped>
.price
  font-weight 500
  font-size 48px
  color #FF823A
  small
    margin-left 10px
    font-size 32px
    color #858B9C
</style>


      

API

ActionBar Props

属性说明类型默认值备注
actions按钮组Array<{text, disabled, onClick}>-text为按钮文案,disabled为是否禁用该按钮,onClick为点击事件响应函数,传参数与click事件相同

ActionBar Slots

default

左侧文案内容

ActionBar Events

@click(event, action)

按钮点击事件

属性说明类型
actionactions列表中与被点击按钮对应的对象Object: {text, disabled, …}