See999 5 年 前
コミット
b6505f2829
共有3 個のファイルを変更した11817 個の追加14277 個の削除を含む
  1. 11782 14257
      package-lock.json
  2. 1 0
      package.json
  3. 34 20
      src/App.vue

File diff suppressed because it is too large
+ 11782 - 14257
package-lock.json


+ 1 - 0
package.json ファイルの表示

@@ -18,6 +18,7 @@
18 18
   },
19 19
   "dependencies": {
20 20
     "axios": "^0.19.0",
21
+    "better-scroll": "^1.15.2",
21 22
     "cropperjs": "^1.4.3",
22 23
     "element-ui": "^2.9.1",
23 24
     "lib-flexible": "^0.3.2",

+ 34 - 20
src/App.vue ファイルの表示

@@ -1,41 +1,55 @@
1 1
 <template>
2
-  <div id="app">
2
+  <div id="app" ref="wrapper">
3 3
     <!-- <img src="./assets/logo.png"> -->
4
-    <router-view  v-if="isRouterAlive" />
4
+    <router-view v-if="isRouterAlive" />
5 5
   </div>
6 6
 </template>
7 7
 
8 8
 <script>
9
+import BScroll from "better-scroll";
9 10
 export default {
10
-  name: 'App',
11
-  provide () {
11
+  name: "App",
12
+  provide() {
12 13
     return {
13 14
       reload: this.reload
14
-    }
15
+    };
15 16
   },
16
-  data () {
17
+  data() {
17 18
     return {
18 19
       isRouterAlive: true
19
-    }
20
+    };
20 21
   },
21 22
   methods: {
22
-    reload () {
23
-      this.isRouterAlive = false
24
-      this.$nextTick(function () {
25
-        this.isRouterAlive = true
26
-      })
23
+    reload() {
24
+      this.isRouterAlive = false;
25
+      this.$nextTick(function() {
26
+        this.isRouterAlive = true;
27
+      });
27 28
     }
28 29
   },
29 30
   watch: {
30
-    '$route': function (to, from) {
31
-      document.body.scrollTop = 0
32
-      document.documentElement.scrollTop = 0
31
+    $route: function(to, from) {
32
+      document.body.scrollTop = 0;
33
+      document.documentElement.scrollTop = 0;
33 34
     }
35
+  },
36
+  mounted() {
37
+    this.$nextTick(() => {
38
+      //$refs绑定元素
39
+      if (!this.scroll) {
40
+        this.scroll = new BScroll(this.$refs.wrapper, {
41
+          //开启点击事件 默认为false
42
+          click: true
43
+        });
44
+        // console.log(this.scroll)
45
+      } else if (!this.$refs.wrapper) {
46
+        return;
47
+      } else {
48
+        this.scroll.refresh();
49
+      }
50
+    });
34 51
   }
35
-
36
-}
52
+};
37 53
 </script>
38 54
 
39
-<style>
40
-
41
-</style>
55
+<style></style>