canvasLove.vue 552 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <canvas class="canvasBox" :id="'canvasId_' + canvasId"></canvas>
  3. </template>
  4. <script>
  5. export default {
  6. props: {
  7. canvasId: {
  8. type: String,
  9. default: '1'
  10. }
  11. },
  12. data() {
  13. return {
  14. canvasObj: value
  15. };
  16. },
  17. created() {
  18. // 保存画布对象
  19. this.canvasObj = uni.createCanvasContext('canvasId' + this.canvasId, this);
  20. // 获取可使用窗口宽度
  21. let width = uni.getSystemInfoSync().windowWidth
  22. this.width = `${width}px`
  23. }
  24. };
  25. </script>
  26. <style>
  27. .canvasBox{
  28. width: 110rpx;
  29. height: 370rpx;
  30. }
  31. </style>