popup.nvue
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
<div class="wrapper">
<text class="title">{{title}}</text>
<scroller class="scroller">
<div>
<text class="content">{{content}}</text>
</div>
<div>
<text style="color: red; font-size: 30rpx;">以下为 Popup 内部滚动示例:</text>
</div>
<div class="cell" v-for="(item, index) in lists" @click="handle(item)" :key="index">
<text class="text">{{item}}</text>
</div>
</scroller>
<div class="message-wrapper">
<text class="send-message" @click="sendMessage">向页面发送消息</text>
</div>
</div>
</template>
<script>
export default {
data() {
return {
title: '',
content: '',
lists: [],
}
},
created() {
const vm = this;
for (let i = 1; i < 20; i++) {
this.lists.push('item' + i);
}
uni.$on('page-popup', (data) => {
vm.title = data.title;
vm.content = data.content;
})
},
beforeDestroy() {
uni.$off('drawer-page')
},
methods: {
sendMessage() {
const subNVue = uni.getCurrentSubNVue()
uni.$emit('popup-page', {
title: '已读完!',
})
},
handle(item, index) {
const subNVue = uni.getCurrentSubNVue()
uni.$emit('popup-page', {
type: 'interactive',
info: item + ' 该元素被点击了!',
})
}
}
}
</script>
<style>
.wrapper {
flex-direction: column;
justify-content: space-between;
padding: 10rpx 15rpx;
background-color: #F4F5F6;
border-radius: 4rpx;
}
.title {
height: 100rpx;
line-height: 100rpx;
border-bottom-style: solid;
border-bottom-width: 1rpx;
border-bottom-color: #CBCBCB;
flex: 0;
font-size: 30rpx;
}
.scroller {
height: 400rpx;
padding: 8rpx 15rpx;
}
.content {
color: #555555;
font-size: 32rpx;
}
.message-wrapper {
flex: 0;
border-top-style: solid;
border-top-width: 1rpx;
border-top-color: #CBCBCB;
height: 80rpx;
align-items: flex-end;
}
.send-message {
font-size: 30rpx;
line-height: 80rpx;
color: #00CE47;
margin-left: 20rpx;
}
.cell {
margin: 10rpx;
padding: 20rpx 0;
top: 10rpx;
align-items: center;
justify-content: center;
border-radius: 10rpx;
background-color: #5989B9;
}
.text {
font-size: 30rpx;
text-align: center;
color: white;
}
</style>