sign.uvue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <cl-page>
  3. <cl-sign
  4. ref="signRef"
  5. :height="isFullscreen ? windowHeight - 200 : 200"
  6. :width="windowWidth"
  7. :enable-brush="isBrush"
  8. ></cl-sign>
  9. <view class="p-3">
  10. <cl-list>
  11. <cl-list-item label="操作">
  12. <cl-button type="info" @click="clear">清空</cl-button>
  13. <cl-button @click="preview">预览</cl-button>
  14. </cl-list-item>
  15. <cl-list-item label="全屏">
  16. <cl-switch v-model="isFullscreen"></cl-switch>
  17. </cl-list-item>
  18. <cl-list-item label="毛笔效果">
  19. <cl-switch v-model="isBrush"></cl-switch>
  20. </cl-list-item>
  21. </cl-list>
  22. </view>
  23. </cl-page>
  24. </template>
  25. <script setup lang="ts">
  26. import { ref } from "vue";
  27. import DemoItem from "../components/item.uvue";
  28. const { windowWidth, windowHeight } = uni.getWindowInfo();
  29. const isFullscreen = ref(false);
  30. const isBrush = ref(true);
  31. const signRef = ref<ClSignComponentPublicInstance | null>(null);
  32. function clear() {
  33. signRef.value!.clear();
  34. }
  35. function preview() {
  36. signRef.value!.toPng().then((url) => {
  37. uni.previewImage({
  38. urls: [url]
  39. });
  40. });
  41. }
  42. </script>