Modify the default button

This article will show you how to use a custom component button instead of the default button

Set global configuration

Hide the default button

First hide the default action button of the form by setting the global configuration

  1. {
  2. submitBtn: false,
  3. resetBtn: false
  4. }

Custom form action buttons

::: demo

  1. <template>
  2. <div>
  3. <form-create :rule="rule" v-model="fApi" :option="options"/>
  4. <ElButton type="primary" plain @click="submit">Submit</ElButton>
  5. <ElButton aligen="center" plain @click="reset">Reset</ElButton>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. data(){
  11. return {
  12. fApi:{},
  13. options:{
  14. submitBtn:false
  15. },
  16. rule:[
  17. {
  18. type:'checkbox',
  19. field:'label',
  20. title:'label',
  21. value: [],
  22. options:[
  23. {label:'easyToUse',value:0},
  24. {label:'fast',value:1},
  25. {label:'efficient',value:2},
  26. {label:'allRound',value:3},
  27. ],
  28. validate: [{type: 'array', min:3, required: true, message:'Select at least 3'}]
  29. }
  30. ]
  31. }
  32. },
  33. methods:{
  34. submit(){
  35. this.fApi.submit((formData, $f)=>{
  36. alert(JSON.stringify(formData));
  37. })
  38. },
  39. reset(){
  40. this.fApi.resetFields();
  41. }
  42. }
  43. }
  44. </script>

:::