File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export default create({
112
112
}
113
113
return props .images
114
114
})
115
+
115
116
// 设置当前选中第几个
116
117
const setActive = (active : number ) => {
117
118
if (active !== state .active ) {
@@ -126,10 +127,10 @@ export default create({
126
127
done : () => closeDone ()
127
128
})
128
129
}
130
+
129
131
// 执行关闭
130
132
const closeDone = () => {
131
133
state .showPop = false
132
-
133
134
emit (' close' )
134
135
}
135
136
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ import {
37
37
computed ,
38
38
ref ,
39
39
watch ,
40
+ onMounted ,
41
+ onUnmounted ,
40
42
VNode
41
43
} from ' vue'
42
44
import { createComponent } from ' @/packages/utils/create'
@@ -461,6 +463,33 @@ export default create({
461
463
}
462
464
)
463
465
466
+ // 横竖屏切换
467
+ const width = ref (window .innerWidth )
468
+ const height = ref (window .innerHeight )
469
+ const updateDimensions = () => {
470
+ width .value = window .innerWidth
471
+ height .value = window .innerHeight
472
+ }
473
+
474
+ // 监听 width 和 height 的变化
475
+ watch ([width , height ], () => {
476
+ Taro .nextTick (() => {
477
+ init ()
478
+ })
479
+ eventCenter .once ((getCurrentInstance () as any ).router .onReady , () => {
480
+ init ()
481
+ })
482
+ })
483
+
484
+ onMounted (() => {
485
+ window .addEventListener (' resize' , updateDimensions )
486
+ updateDimensions () // 初始化尺寸
487
+ })
488
+
489
+ onUnmounted (() => {
490
+ window .removeEventListener (' resize' , updateDimensions )
491
+ })
492
+
464
493
return {
465
494
state ,
466
495
refRandomId ,
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ import {
36
36
nextTick ,
37
37
ref ,
38
38
watch ,
39
+ onMounted ,
40
+ onUnmounted ,
39
41
VNode
40
42
} from ' vue'
41
43
import { createComponent } from ' @/packages/utils/create'
@@ -442,6 +444,30 @@ export default create({
442
444
}
443
445
)
444
446
447
+ // 横竖屏切换
448
+ const width = ref (window .innerWidth )
449
+ const height = ref (window .innerHeight )
450
+ const updateDimensions = () => {
451
+ width .value = window .innerWidth
452
+ height .value = window .innerHeight
453
+ }
454
+
455
+ // 监听 width 和 height 的变化
456
+ watch ([width , height ], () => {
457
+ nextTick (() => {
458
+ init ()
459
+ })
460
+ })
461
+
462
+ onMounted (() => {
463
+ window .addEventListener (' resize' , updateDimensions )
464
+ updateDimensions () // 初始化尺寸
465
+ })
466
+
467
+ onUnmounted (() => {
468
+ window .removeEventListener (' resize' , updateDimensions )
469
+ })
470
+
445
471
return {
446
472
state ,
447
473
classesInner ,
You can’t perform that action at this time.
0 commit comments