File tree 2 files changed +36
-11
lines changed 2 files changed +36
-11
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
- export default {
3
- onLaunch : function () {
4
- console .log (' App Launch' )
5
- },
6
- onShow : function () {
7
- console .log (' App Show' )
8
- },
9
- onHide : function () {
10
- console .log (' App Hide' )
2
+ export default {
3
+ onLaunch : function () {
4
+ this .appUpdate ()
5
+ },
6
+ onShow : function () {
7
+ },
8
+ onHide : function () {
9
+ },
10
+ methods: {
11
+ // 系统更新
12
+ appUpdate () {
13
+ const updateManager = uni .getUpdateManager ();
14
+ updateManager .onCheckForUpdate (function (res ) {
15
+ // 请求完新版本信息的回调
16
+ // console.log(res.hasUpdate);
17
+ });
18
+ updateManager .onUpdateReady (function (res ) {
19
+ uni .showModal ({
20
+ title: ' 更新提示' ,
21
+ content: ' 新版本已经准备好,是否重启应用?' ,
22
+ success (res ) {
23
+ if (res .confirm ) {
24
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
25
+ updateManager .applyUpdate ();
26
+ }
27
+ }
28
+ });
29
+ });
30
+ updateManager .onUpdateFailed (function (res ) {
31
+ // 新的版本下载失败
32
+ });
11
33
}
12
34
}
35
+ }
13
36
</script >
14
37
15
38
<style lang="scss">
16
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
17
- @import " uview-ui/index.scss" ;
39
+ /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
40
+ @import " uview-ui/index.scss" ;
18
41
</style >
Original file line number Diff line number Diff line change @@ -26,3 +26,5 @@ import httpApi from '@/api/http.api.js'
26
26
Vue . use ( httpApi , app )
27
27
28
28
app . $mount ( )
29
+
30
+
You can’t perform that action at this time.
0 commit comments