view.uvue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <page-head title="view"></page-head>
  3. <view id="view" class="main" :hover-class="hover_class ? 'is-parent-hover' : 'none'">
  4. <view id="view-child1" class="test-view" :class="isDarkMode ? 'theme-dark' : 'theme-light'" :hover-class="hover_class ? 'is-hover' : 'none'" :hover-stop-propagation="stop_propagation"
  5. :hover-start-time="start_time" :hover-stay-time="stay_time">
  6. </view>
  7. </view>
  8. <scroll-view style="flex: 1">
  9. <view class="content">
  10. <boolean-data :defaultValue="false" title="是否指定按下去的样式类" @change="change_hover_class_boolean"></boolean-data>
  11. <boolean-data :defaultValue="false" title="是否阻止本节点的祖先节点出现点击态"
  12. @change="change_stop_propagation_boolean"></boolean-data>
  13. <enum-data :items="start_time_enum" title="按住后多久出现点击态" @change="radio_change_start_time_enum"></enum-data>
  14. <enum-data :items="stay_time_enum" title="手指松开后点击态保留时间" @change="radio_change_stay_time_enum"></enum-data>
  15. </view>
  16. </scroll-view>
  17. </template>
  18. <script>
  19. import { ItemType } from '@/components/enum-data/enum-data-types'
  20. import { state } from '@/store/index.uts'
  21. export default {
  22. data() {
  23. return {
  24. hover_class: false,
  25. stop_propagation: false,
  26. start_time: 50,
  27. stay_time: 400,
  28. start_time_enum: [{ "value": 50, "name": "50毫秒" }, { "value": 200, "name": "200毫秒" }] as ItemType[],
  29. stay_time_enum: [{ "value": 400, "name": "400毫秒" }, { "value": 200, "name": "200毫秒" }] as ItemType[]
  30. }
  31. },
  32. computed: {
  33. isDarkMode() : boolean {
  34. return state.isDarkMode
  35. }
  36. },
  37. methods: {
  38. change_hover_class_boolean(checked : boolean) {
  39. this.hover_class = checked
  40. },
  41. change_stop_propagation_boolean(checked : boolean) {
  42. this.stop_propagation = checked
  43. },
  44. radio_change_start_time_enum(time : number) {
  45. this.start_time = time
  46. },
  47. radio_change_stay_time_enum(time : number) {
  48. this.stay_time = time
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. .main {
  55. padding: 5px 0;
  56. flex-direction: row;
  57. justify-content: center;
  58. }
  59. .test-view {
  60. height: 200px;
  61. width: 200px;
  62. background-color: var(--list-background-color,#ffffff);
  63. }
  64. .is-hover {
  65. background-color: #179b16;
  66. }
  67. .is-parent-hover {
  68. background-color: #aa0000;
  69. }
  70. </style>