dialog-4.uvue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="dialog-container">
  3. <view class="dialog-content">
  4. <text>title: {{ title }}</text>
  5. <button class="mt-10" @click="closeDialog">
  6. closeDialog
  7. </button>
  8. <button class="mt-10" @click="closeThisDialog">
  9. closeThisDialog
  10. </button>
  11. <button class="mt-10" @click="openDialog3">
  12. open dialog 3
  13. </button>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {
  19. state,
  20. setLifeCycleNum
  21. } from '@/store/index.uts'
  22. export default {
  23. data() {
  24. return {
  25. title: 'dialog 4'
  26. }
  27. },
  28. onShow() {
  29. console.log('dialog 4 onShow')
  30. // 自动化测试
  31. setLifeCycleNum(state.lifeCycleNum + 1)
  32. },
  33. onUnload() {
  34. console.log('dialog 4 onUnload')
  35. // 自动化测试
  36. setLifeCycleNum(state.lifeCycleNum - 5)
  37. },
  38. methods: {
  39. closeDialog() {
  40. uni.closeDialogPage({
  41. success(res) {
  42. console.log('closeDialog success', res)
  43. },
  44. fail(err) {
  45. console.log('closeDialog fail', err)
  46. },
  47. complete(res) {
  48. console.log('closeDialog complete', res)
  49. }
  50. })
  51. },
  52. closeThisDialog() {
  53. uni.closeDialogPage({
  54. dialogPage: this.$page,
  55. success(res) {
  56. console.log('closeThisDialog success', res)
  57. },
  58. fail(err) {
  59. console.log('closeThisDialog fail', err)
  60. },
  61. complete(res) {
  62. console.log('closeThisDialog complete', res)
  63. }
  64. })
  65. },
  66. openDialog3(){
  67. uni.openDialogPage({url: '/pages/API/dialog-page/dialog-3'})
  68. }
  69. }
  70. }
  71. </script>
  72. <style>
  73. .dialog-container {
  74. width: 100%;
  75. height: 100%;
  76. background-color: rgba(0, 0, 0, 0.3);
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. }
  81. .dialog-content {
  82. width: 80%;
  83. padding: 10px;
  84. background-color: #fff;
  85. border-radius: 6px;
  86. }
  87. .mt-10 {
  88. margin-top: 10px;
  89. }
  90. </style>