lightButton.vue 1.5 KB
Newer Older
朱国瑞's avatar
朱国瑞 committed
1
<template>
朱国瑞's avatar
朱国瑞 committed
2
  <div class="btn-container" :class="{'mobile':_isMobile,'pc':!_isMobile}">
朱国瑞's avatar
朱国瑞 committed
3 4 5 6 7 8 9
    <img class="btn-img" src="../assets/images/gesture/light-btn-bg.png" />
    <div class="btn-text light-button-text">{{text}}</div>
    <slot name="body"></slot>
  </div>
</template>

<script >
朱国瑞's avatar
朱国瑞 committed
10
import { isMobile } from "../common/util";
朱国瑞's avatar
朱国瑞 committed
11 12 13 14 15 16

// defineProps({
//   msg: String
// });
export default {
  data() {
朱国瑞's avatar
朱国瑞 committed
17 18 19
    return {
      _isMobile: false
    };
朱国瑞's avatar
朱国瑞 committed
20 21 22 23 24 25 26 27 28
  },
  props: ["text"],
  methods: {
    confirm() {
      this.$emit("update:confirm", { type: "confirm" });
    },
    cancel() {
      this.$emit("update:confirm", { type: "cancel" });
    }
朱国瑞's avatar
朱国瑞 committed
29 30 31
  },
  created() {
    this._isMobile = isMobile();
朱国瑞's avatar
朱国瑞 committed
32 33 34 35 36
  }
};
</script>

<style lang="scss" scoped>
朱国瑞's avatar
朱国瑞 committed
37 38 39 40 41 42 43 44 45 46 47 48
.btn-container {
  position: relative;
  color: #ffffff;

  img,
  div,
  button {
    position: absolute;
    left: 0;
    top: 0;
  }
  &.pc {
朱国瑞's avatar
朱国瑞 committed
49 50 51 52
    width: 436px;
    height: 77.7px;
    line-height: 77.7px;
  }
朱国瑞's avatar
朱国瑞 committed
53 54 55 56 57 58 59
  &.mobile {
    width: 5.8133rem;
    height: 1.036rem;
    line-height: 1.036rem;
  }
}
.pc {
朱国瑞's avatar
朱国瑞 committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  .btn-text {
    width: 100%;
    text-align: center;
    font-size: 44px;
    letter-spacing: 0.2em;
    font-weight: bold;
  }
  .btn-img {
    width: 100%;
    height: 100%;
  }

  .light-button-text {
    letter-spacing: 0.2em;
  }
}
朱国瑞's avatar
朱国瑞 committed
76
.mobile {
朱国瑞's avatar
朱国瑞 committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
  .btn-text {
    width: 100%;
    text-align: center;
    font-size: 0.5867rem;
    letter-spacing: 0.2em;
    font-weight: bold;
  }
  .btn-img {
    width: 100%;
    height: 100%;
  }

  .light-button-text {
    letter-spacing: 0.2em;
  }
}
</style>