UNPKG

2.96 kBPlain TextView Raw
1<template>
2
3 <div class="app" @lifecycle="lifecycle">
4
5 <!-- 顶部导航 -->
6 <div class="nav">
7 <text class="nav-title">{{title}}</text>
8 <icon class="nav-back" @click="goBack"></icon>
9 </div>
10
11 <!-- 页面内容 -->
12 <scroller class="app">
13
14 </scroller>
15
16 </div>
17
18</template>
19
20<style scoped>
21 .app {
22 flex: 1;
23 }
24 .nav {
25 width: 750px;
26 height: 96px;
27 display: flex;
28 background-color: #3EB4FF;
29 }
30 .nav-back {
31 position: absolute;
32 left: 0;
33 top: 0;
34 width: 96px;
35 height: 96px;
36 line-height: 96px;
37 text-align: center;
38 font-size: 38px;
39 color: #ffffff;
40 content: 'tb-back';
41 }
42 .nav-title {
43 flex: 1;
44 color: #ffffff;
45 text-align: center;
46 line-height: 96px;
47 font-size: 32px;
48 font-weight: 300;
49 }
50</style>
51<script>
52 const eeui = app.requireModule('eeui');
53
54 export default {
55 data() {
56 return {
57 title: '空白模板'
58 }
59 },
60
61 mounted() {
62 //页面挂载
63 },
64
65 methods: {
66 /**
67 * 生命周期
68 * @param res
69 */
70 lifecycle(res) {
71 switch (res.status) {
72 case "ready":
73 //页面挂载(初始化)
74 break;
75
76 case "resume":
77 //页面激活(恢复)
78 break;
79
80 case "pause":
81 //页面失活(暂停)
82 break;
83
84 case "destroy":
85 //页面停止(销毁)
86 break;
87 }
88 },
89
90 /**
91 * 打开新页面
92 * @param url (String)页面地址
93 * @param params (Object)传递参数
94 * @param replace (Boolean)打开新页面后关闭当前页面
95 */
96 goForward(url, params, replace) {
97 let pageName = null;
98 if (replace === true) {
99 let pageInfo = eeui.getPageInfo();
100 pageName = pageInfo['pageName'];
101 }
102 //
103 eeui.openPage({
104 url: url,
105 pageType: "app",
106 statusBarColor: "#3EB4FF",
107 params: params ? params : {}
108 }, (res) => {
109 if (replace === true && res.status === 'create') {
110 eeui.closePage(pageName);
111 }
112 });
113 },
114
115 /**
116 * 返回上一页(关闭当前页)
117 */
118 goBack() {
119 eeui.closePage();
120 },
121 }
122 }
123</script>