-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.vue
More file actions
52 lines (50 loc) · 1.52 KB
/
App.vue
File metadata and controls
52 lines (50 loc) · 1.52 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
<script>
export default {
onLaunch: function(options) {
console.log('App Launch')
// #ifdef H5
this.startup({
appOptions: options
})
// #endif
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods: {
startup({
appOptions,
notInitPages = [], // 不需要初始化的页面,例如只作单页显示,不会返回到其他业务页面的页面
notEnterPages = [] // 不作为入口页的页面
}) {
notInitPages.push('pages/init/init') // 可以防止init页面onLoad调用两次
notEnterPages.push('pages/init/init')
// 验证集合是否存在页面,不存在则该页面作为入口页,否则入口页为首页
if (!notInitPages.includes(appOptions.path) && !notEnterPages.includes(appOptions.path)) {
let path = appOptions.path
let query = appOptions.query
let queryString = ''
for (let key in query) {
queryString += `${key}=${query[key]}&`
}
if (queryString) {
queryString = `?${queryString.replace(/&$/, '')}`
}
let redirectPath = encodeURIComponent('/' + path + queryString)
let url = `/pages/init/init?redirect=${redirectPath}`
uni.reLaunch({
url
})
}
}
}
}
</script>
<style>
/* 引入全局样式 */
@import 'common/css/app.css';
/*每个页面公共css */
</style>