Button 按钮

Scan me!

按钮组件,可配置多种不同的按钮样式

引入

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

代码演示

基本

Button 按钮 - 图2

  1. <template>
  2. <div class="md-example-child md-example-child-button md-example-child-button-0">
  3. <md-button type="default">Default</md-button>
  4. <md-button type="default" inactive>Default Inactive</md-button>
  5. <md-button type="primary">Primary</md-button>
  6. <md-button type="primary" inactive>Primary Inactive</md-button>
  7. <md-button type="primary" loading>Loading</md-button>
  8. <md-button type="warning">Warning</md-button>
  9. <md-button type="warning" inactive>Warning Inactive</md-button>
  10. <md-button type="disabled">Disabled</md-button>
  11. </div>
  12. </template>
  13. <script>
  14. import {Button} from 'mand-mobile'
  15. export default {
  16. name: 'button-demo',
  17. components: {
  18. [Button.name]: Button,
  19. },
  20. }
  21. </script>
  22.  

圆角按钮

Button 按钮 - 图3

  1. <template>
  2. <div class="md-example-child md-example-child-button md-example-child-button-2">
  3. <md-button type="default" round>Default & Round</md-button>
  4. <md-button type="primary" round>Primary & Round</md-button>
  5. <md-button type="warning" round>Warning & Round</md-button>
  6. <md-button type="disabled" round>Disabled & Round</md-button>
  7. </div>
  8. </template>
  9. <script>
  10. import {Button} from 'mand-mobile'
  11. export default {
  12. name: 'button-demo',
  13. components: {
  14. [Button.name]: Button,
  15. },
  16. }
  17. </script>
  18.  

线性按钮

Button 按钮 - 图4

  1. <template>
  2. <div class="md-example-child md-example-child-button md-example-child-button-1">
  3. <md-button type="default" plain>Default & Plain</md-button>
  4. <md-button type="primary" plain>Primary & Plain</md-button>
  5. <md-button type="warning" plain>Warning & Plain</md-button>
  6. <md-button type="disabled" plain>Disabled & Plain</md-button>
  7. <md-button type="primary" plain round>Primary & Plain & Round</md-button>
  8. <md-button type="primary" plain round loading>Primary & Plain & Loading</md-button>
  9. </div>
  10. </template>
  11. <script>
  12. import {Button} from 'mand-mobile'
  13. export default {
  14. name: 'button-demo',
  15. components: {
  16. [Button.name]: Button,
  17. },
  18. }
  19. </script>
  20.  

行内按钮

Button 按钮 - 图5

  1. <template>
  2. <div class="md-example-child md-example-child-button md-example-child-button-3">
  3. <div class="md-example-section">
  4. <md-button type="primary" icon="edit" inline>Inline Primary</md-button>
  5. <md-button type="primary" inline plain>Inline Plain</md-button>
  6. </div>
  7. <div class="md-example-section">
  8. <md-button type="warning" size="small" inline>Warning</md-button>
  9. <md-button type="disabled" size="small" inline>Disabled</md-button>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import {Button} from 'mand-mobile'
  15. export default {
  16. name: 'button-demo',
  17. components: {
  18. [Button.name]: Button,
  19. },
  20. }
  21. </script>
  22. <style lang="stylus" scoped>
  23. .md-example-child-button-3
  24. .md-example-section
  25. float left
  26. width 100%
  27. margin-bottom 10px
  28. .md-button
  29. float left
  30. </style>
  31.  

文字链接按钮

Button 按钮 - 图6

  1. <template>
  2. <div class="md-example-child md-example-child-button md-example-child-button-3">
  3. <md-button type="link" icon="message">评论</md-button>
  4. <md-button type="link" inactive>去看看<md-icon name="arrow-right" size="md"></md-icon></md-button>
  5. </div>
  6. </template>
  7. <script>
  8. import {Button, Icon} from 'mand-mobile'
  9. export default {
  10. name: 'button-demo',
  11. components: {
  12. [Button.name]: Button,
  13. [Icon.name]: Icon,
  14. },
  15. }
  16. </script>
  17. <style lang="stylus" scoped>
  18. .md-example-child-button-3
  19. .md-example-box-content
  20. float left
  21. width 100%
  22. padding 60px h-gap-lg
  23. color color-text-base
  24. font-size font-minor-large
  25. text-align left
  26. background color-bg-base
  27. box-sizing border-box
  28. line-height 1.5
  29. text-indent 2em
  30. .md-button
  31. float left
  32. </style>
  33.  

API

Button Props

属性说明类型默认值备注
type样式Stringdefaultdefault, primary, warning, disabled, link
native-type类型Stringbutton-
size尺寸Stringlargelarge/small
plain朴素Booleanfalse-
round圆角Booleanfalse-
inline行内Booleanfalse-
icon图标String-可选值请参考组件Icon
icon-svg使用svg图标Booleanfalse-
inactive未激活Booleanfalseinactive设为truedisabled类型的按钮都无法点击,前者一般用于表单校验无效等主观因素,后者用于无权限或无库存等客观因素
loading加载中状态Booleanfalse-

Button Events

@click(event)

按钮点击事件