Skip to content

Commit 0fbdcac

Browse files
committed
feat: 新增 subnvue 示例
1 parent 2122183 commit 0fbdcac

7 files changed

Lines changed: 531 additions & 0 deletions

File tree

‎pages.json‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,49 @@
255255
"navigationBarTitleText": "授权登录"
256256
}
257257
},
258+
// #ifdef APP-PLUS
259+
{
260+
"path": "pages/API/subnvue/subnvue",
261+
"style": {
262+
"navigationBarTitleText": "SubNvue",
263+
"app-plus": {
264+
"titleNView":false,
265+
"subNVues": [{
266+
"id": "drawer",
267+
"path": "pages/API/subnvue/drawer",
268+
"type": "popup",
269+
"style": {
270+
"width": "50%"
271+
}
272+
}, {
273+
"id": "popup",
274+
"path": "pages/API/subnvue/popup",
275+
"type": "popup",
276+
"style": {
277+
"margin":"auto",
278+
"width": "80%",
279+
"height": "300px"
280+
}
281+
}, {
282+
"id": "video_mask",
283+
"path": "pages/API/subnvue/video-mask",
284+
"style": {
285+
"position": "absolute",
286+
"bottom": "10px",
287+
"left": "0",
288+
"width": "230px",
289+
"height": "110px",
290+
"background": "transparent"
291+
}
292+
}, {
293+
"id": "nav",
294+
"path": "pages/API/subnvue/nav",
295+
"type": "navigationBar"
296+
}]
297+
}
298+
}
299+
},
300+
// #endif
258301
{
259302
"path": "pages/API/get-user-info/get-user-info",
260303
"style": {

‎pages/API/subnvue/drawer.nvue‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<div class="wrapper">
3+
<text style="color: #8f8f94; margin-bottom: 40px;">左侧列表</text>
4+
<list style="height: 450px;">
5+
<cell v-for="item in lists" :key="item.id">
6+
<div class="text-wrapper">
7+
<text style="font-size: 30px; ">{{item.name}}</text>
8+
<text class="icon">&#xe583;</text>
9+
</div>
10+
</cell>
11+
</list>
12+
<div style="flex: 1; text-align: center;">
13+
<div class="close-drawer" @click="hideDrawer">
14+
<text style="font-size: 34px; text-align: center;">关闭抽屉</text>
15+
</div>
16+
</div>
17+
</div>
18+
</template>
19+
20+
<script>
21+
export default {
22+
data() {
23+
return {
24+
lists: [],
25+
}
26+
},
27+
beforeCreate() {
28+
const domModule = weex.requireModule('dom')
29+
domModule.addRule('fontFace', {
30+
fontFamily: "unibtn",
31+
'src': "url('../../../static/uni.ttf')"
32+
});
33+
},
34+
created() {
35+
for(let i = 0; i < 5; i++){
36+
this.lists.push({
37+
id: i,
38+
name: 'Item' + i,
39+
});
40+
}
41+
},
42+
methods: {
43+
hideDrawer() {
44+
uni.subNVue.getSubNVueById('drawer').hide('auto')
45+
}
46+
}
47+
}
48+
</script>
49+
50+
<style>
51+
.wrapper {
52+
display: flex;
53+
flex-direction: column;
54+
text-align: center;
55+
padding: 60px 0px 0px 20px;
56+
background-color: #F4F5F6;
57+
}
58+
.text-wrapper {
59+
justify-content: center;
60+
border-bottom-style: solid;
61+
border-bottom-width: 1px;
62+
border-bottom-color: rgba(0,0,0,.2);
63+
margin-bottom: 35px;
64+
padding-bottom: 15px;
65+
}
66+
.close-drawer {
67+
background-color: #f8f8f8;
68+
width: 300px;
69+
padding: 15px;
70+
border-radius: 20px;
71+
border-style: solid;
72+
border-width: 1px;
73+
border-color: rgba(0,0,0,.2);
74+
}
75+
.icon {
76+
position: absolute;
77+
right: 10px;
78+
color: #000000;
79+
font-family: unibtn;
80+
font-size: 30px;
81+
font-weight: 400;
82+
}
83+
</style>

‎pages/API/subnvue/nav.nvue‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<template>
2+
<div class="wrapper">
3+
<div class="status-bar"></div>
4+
<div class="nav" @click="back">
5+
<text class="back">&#xe582;</text>
6+
<text style="font-size: 32px;">nvue 渐变色标题栏</text>
7+
</div>
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
data() {
14+
return {}
15+
},
16+
beforeCreate() {
17+
const domModule = weex.requireModule('dom')
18+
domModule.addRule('fontFace', {
19+
fontFamily: "unibtn",
20+
'src': "url('../../../static/uni.ttf')"
21+
});
22+
},
23+
methods: {
24+
back() {
25+
uni.navigateBack();
26+
}
27+
},
28+
}
29+
</script>
30+
31+
<style>
32+
.wrapper {
33+
background-image: linear-gradient(to right, #e498e1, #e60000);
34+
flex-direction: column;
35+
}
36+
.status-bar {
37+
flex: 1;
38+
}
39+
.nav {
40+
position: relative;
41+
height: 88px;
42+
flex-shrink: 0;
43+
justify-content: center;
44+
align-items: center;
45+
}
46+
.back {
47+
position: absolute;
48+
left: 3px;
49+
color: #000000;
50+
font-family: unibtn;
51+
font-size: 54px;
52+
}
53+
</style>

‎pages/API/subnvue/popup.nvue‎

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

0 commit comments

Comments
 (0)