Authored by ccbikai

全局拦截链接跳转

@@ -14,3 +14,13 @@ @@ -14,3 +14,13 @@
14 * 1. cookie 操作请使用 yoho-cookie 文档:https://github.com/florian/cookie.js 14 * 1. cookie 操作请使用 yoho-cookie 文档:https://github.com/florian/cookie.js
15 * 2. 查询字符串读取 请使用 yoho-qs 15 * 2. 查询字符串读取 请使用 yoho-qs
16 */ 16 */
  17 +const $ = require('yoho-jquery');
  18 +const interceptClick = require('common/intercept-click');
  19 +
  20 +$(() => {
  21 + $('body').on('click', 'a[href]', function() {
  22 + // 拦截跳转
  23 + interceptClick($(this).attr('href'));
  24 + return false;
  25 + });
  26 +});
@@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
7 const qs = require('yoho-qs'); 7 const qs = require('yoho-qs');
8 const contentCode = require('content-code'); 8 const contentCode = require('content-code');
9 const bus = require('common/vue-bus'); 9 const bus = require('common/vue-bus');
10 - const interceptClick = require('common/intercept-click');  
11 10
12 const tab = require('channel/tab.vue'); 11 const tab = require('channel/tab.vue');
13 const resources = require('component/resources/index.vue'); 12 const resources = require('component/resources/index.vue');
@@ -27,13 +26,6 @@ @@ -27,13 +26,6 @@
27 bus.$on('contentCode.change', (code) => { 26 bus.$on('contentCode.change', (code) => {
28 this.contentCode = code; 27 this.contentCode = code;
29 }); 28 });
30 - },  
31 - ready() {  
32 - $('.resources').on('click', 'a', function() {  
33 - // 拦截跳转  
34 - interceptClick($(this).attr('href'));  
35 - return false;  
36 - });  
37 } 29 }
38 }; 30 };
39 </script> 31 </script>
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 </template> 14 </template>
15 15
16 <script> 16 <script>
17 - const interceptClick = require('common/intercept-click');  
18 -  
19 module.exports = { 17 module.exports = {
20 data() { 18 data() {
21 return { 19 return {
@@ -28,13 +26,6 @@ @@ -28,13 +26,6 @@
28 }).then((res) => { 26 }).then((res) => {
29 this.list = res.data; 27 this.list = res.data;
30 }); 28 });
31 - },  
32 - ready() {  
33 - $('.sidebar').on('click', 'a', function() {  
34 - // 拦截跳转  
35 - interceptClick($(this).attr('href'));  
36 - return false;  
37 - });  
38 } 29 }
39 }; 30 };
40 </script> 31 </script>
@@ -28,7 +28,8 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => { @@ -28,7 +28,8 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => {
28 'yoho-vue', 28 'yoho-vue',
29 'yoho-vue-lazyload', 29 'yoho-vue-lazyload',
30 'yoho-vue-swipe', 30 'yoho-vue-swipe',
31 - 'yoho-vue-infinite-scroll' 31 + 'yoho-vue-infinite-scroll',
  32 + './js/index.js' // 全局公有文件
32 ]; 33 ];
33 }); 34 });
34 35