battery.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="battery-container">
  3. <view class="battery-body"><view class="battery" :style="{ width: `${level}%` }"></view></view>
  4. <view class="battery-head"></view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. level: {
  11. type: Number,
  12. default: 0
  13. },
  14. charging: {
  15. type: Boolean,
  16. default: false
  17. }
  18. },
  19. data() {
  20. return {};
  21. },
  22. mounted() {},
  23. methods: {}
  24. };
  25. </script>
  26. <style lang="scss" scoped>
  27. .battery-container {
  28. display: flex;
  29. justify-content: center;
  30. align-items: center;
  31. width: 25px;
  32. height: 10px;
  33. .battery-body {
  34. position: relative;
  35. padding: 1px;
  36. width: 22px;
  37. height: 100%;
  38. border-radius: 1px;
  39. border: $minor-text-color solid 1px;
  40. .battery {
  41. height: 100%;
  42. background-color: $minor-text-color;
  43. }
  44. .charging {
  45. position: absolute;
  46. left: 50%;
  47. top: 50%;
  48. transform: translate(-50%, -50%);
  49. height: 12px;
  50. line-height: 12px;
  51. font-size: 15px;
  52. color: #333;
  53. }
  54. }
  55. .battery-head {
  56. width: 2px;
  57. height: 6px;
  58. background-color: $minor-text-color;
  59. }
  60. }
  61. </style>