float-view.uvue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item>
  5. <view class="flex flex-row items-center">
  6. <cl-icon name="notification-4-fill" class="mr-2"></cl-icon>
  7. <cl-text>{{ t("禁用状态,无法拖拽") }}</cl-text>
  8. </view>
  9. </demo-item>
  10. <demo-item>
  11. <view class="flex flex-row items-center">
  12. <cl-icon name="heart-fill" class="mr-2"></cl-icon>
  13. <cl-text>{{ t("不吸附边缘,任意位置可拖拽") }}</cl-text>
  14. </view>
  15. </demo-item>
  16. <cl-float-view :left="200" :bottom="50" :no-snapping="true">
  17. <view
  18. class="w-[40px] h-[40px] bg-primary-500 flex flex-row items-center justify-center"
  19. @tap="toAlert"
  20. >
  21. <cl-icon name="heart-fill" color="white"></cl-icon>
  22. </view>
  23. </cl-float-view>
  24. <cl-float-view disabled :left="20" :bottom="400" :gap="10">
  25. <view
  26. class="w-[40px] h-[40px] bg-surface-400 rounded-full flex flex-row items-center justify-center"
  27. >
  28. <cl-icon name="notification-4-fill" color="white"></cl-icon>
  29. </view>
  30. </cl-float-view>
  31. </view>
  32. </cl-page>
  33. </template>
  34. <script lang="ts" setup>
  35. import { t } from "@/locale";
  36. import { useUi } from "@/uni_modules/cool-ui";
  37. import DemoItem from "../components/item.uvue";
  38. const ui = useUi();
  39. function toAlert() {
  40. ui.showToast({
  41. message: t("这是一个提示")
  42. });
  43. }
  44. </script>