index.vue 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <view class="gauge-container">
  3. <view class="title">温度类</view>
  4. <canvas class="canvas" canvas-id="canvas"></canvas>
  5. <view class="title">进度类</view>
  6. <canvas class="canvas" canvas-id="canvas2"></canvas>
  7. </view>
  8. </template>
  9. <script>
  10. import Gauge from "./index.js";
  11. export default {
  12. name: "gauge",
  13. data() {
  14. return {};
  15. },
  16. mounted() {
  17. new Gauge({
  18. canvasId: "canvas",
  19. width: 200,
  20. min: 16,
  21. max: 30,
  22. value: 20.5,
  23. unit: "℃",
  24. showTick: true,
  25. });
  26. new Gauge({
  27. canvasId: "canvas2",
  28. value: 80,
  29. lineWidth: 20,
  30. progressColor: ["#2196F3", "#9C27B0", "#F44336"],
  31. valueColor: "blue",
  32. });
  33. },
  34. };
  35. </script>
  36. <style>
  37. .gauge-container {
  38. padding: 20rpx 40rpx;
  39. text-align: left;
  40. }
  41. .title {
  42. margin-bottom: 20rpx;
  43. color: #000;
  44. font-size: 32rpx;
  45. font-weight: 500;
  46. }
  47. .canvas {
  48. width: 200px;
  49. height: 200px;
  50. margin: 40rpx auto;
  51. }
  52. </style>