1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <template> <div class="button" :class="[type, size]"> <!-- 插槽,会将父标签的本文填充到里面 --> <slot></slot> </div> </template>
<script> const options = { // 父组件使用时可以添加的属性 props: ["type", "size"] } export default options; </script>
<!-- 使用scoped可以让CSS样式只对局部元素生效 --> <style scoped> .button { display: inline-block; text-align: center; border-radius: 30px; margin: 5px; font: bold 12px/25px Arial, sans-serif; padding: 0 2px; text-shadow: 1px 1px 1px rgba(255, 255, 255, .22); box-shadow: 1px 1px 1px rgba(0, 0, 0, .29), inset 1px 1px 1px rgba(255, 255, 255, .44); transition: all 0.15s ease; }
.button:hover { box-shadow: 1px 1px 1px rgba(0, 0, 0, .29), inset 1px 1px 2px rgba(0, 0, 0, .5); }
.button:active { box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .8); }
.primary { background-color: #1d6ef9; color: #b5e3f1; }
.danger { background-color: rgb(196, 50, 50); color: white; }
.success { background-color: #a5cd4e; ; color: #3e5706; }
.small { width: 40px; height: 20px; font-size: 10px; line-height: 20px; }
.middle { width: 50px; height: 25px; font-size: 14px; line-height: 25px; }
.large { width: 60px; height: 30px; font-size: 18px; line-height: 30px; } </style>
|