vue 封裝按鈕

weixin_34249678發表於2018-11-20

父元件:

<template>
<openBtn :disabled="isdisabled" @click="updown()">啟用</openBtn>
</template>
<script>
export default {
    data() {
         return {
             isdisabled:false
         }
      },
     methods: {
          updown(){
          }
      }
}
</script>

子元件:

<template>
<div class="open-public-function-btn" @click="clickFunction">
<slot></slot>
</div>
</template>
<script>
export default {
data() {
return {}
},
methods: {
clickFunction(){
this.$emit("click");
}
}
}
</script>
<style >
.open-public-function-btn{
border: 1px solid #5db5ef;
background: #fff;
color: #5db5ef;
font-size: 12px;
height: 26px;
line-height: 26px;
min-width: auto;
padding: 0 16px;
display: inline-block;
border-radius: 4px;
cursor: pointer;
}
.open-public-function-btn:hover{
background-color: #5db5ef;
color: #ffffff;
border: 1px solid #5db5ef;
}
</style>

相關文章