<!-- * @Description: 按钮选择 * @Author: 王晓颖 * @Date: 2020-09-18 09:10:39 --> <template> <div :class="selected?'button-select':'button-no-select'" class="button"> <span :style="{'font-size':size+'rem'}" class="button-text"><slot/></span> </div> </template> <script> export default { name: 'Button1', model: { prop: 'selected', event: 'change' }, props: { size: { type: String, default: '1.4' }, // 文字大小 selected: { type: Boolean, required: true }// 选择状态 }, methods: { change() { // 选中则通知上级,二次点击不予处理 if (this.selected) { this.$emit('click') } } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .button{ cursor: pointer; padding: 1.5rem 1.4rem; color: #fff; /*background: url("../../assets/images/button/button_blue.png") no-repeat;*/ background-size: 100% 100%; margin-right: .5rem; text-align: center; } .button-no-select{ background: url("../../assets/button_images/button_blue.png") no-repeat; color:#009bff; } @keyframes bounce { 0%, 7%, 25%, 36%, 45%, 50% { animation-timing-function: ease-out; transform: translate3d(0, 0, 0); } 15%, 16% { animation-timing-function: ease-in; transform: translate3d(0, -30px, 0); } 30% { animation-timing-function: ease-in; transform: translate3d(0, -16px, 0); } 41% { animation-timing-function: ease-in; transform: translate3d(0, -8px, 0); } 47% { animation-timing-function: ease-in; transform: translate3d(0, -3px, 0); } } .button-select{ background: url("../../assets/button_images/button_yellow.png") no-repeat; color: #fccd14; animation: bounce 2.5s 1 0s both; // keyframe bounce,持续2.5s,播放2次 transform-origin: center bottom; } .button-text{ font-weight: bolder; } </style>