Authored by ccbikai

侧边栏也拦截跳转

@@ -11,6 +11,7 @@ module.exports = (url) => { @@ -11,6 +11,7 @@ module.exports = (url) => {
11 url: url 11 url: url
12 }); 12 });
13 } else { 13 } else {
14 - location.href = url; 14 +
  15 + // location.href = url;
15 } 16 }
16 }; 17 };
@@ -14,8 +14,7 @@ @@ -14,8 +14,7 @@
14 </template> 14 </template>
15 15
16 <script> 16 <script>
17 - // const tab = require('channel/tab.vue');  
18 - // const resources = require('component/resources/index.vue'); 17 + const interceptClick = require('common/intercept-click');
19 18
20 module.exports = { 19 module.exports = {
21 data() { 20 data() {
@@ -23,14 +22,19 @@ @@ -23,14 +22,19 @@
23 list: [] 22 list: []
24 }; 23 };
25 }, 24 },
26 - components: {  
27 - },  
28 created() { 25 created() {
29 $.ajax({ 26 $.ajax({
30 url: '/sidebar' 27 url: '/sidebar'
31 }).then((res) => { 28 }).then((res) => {
32 this.list = res.data; 29 this.list = res.data;
33 }); 30 });
  31 + },
  32 + ready() {
  33 + $('.sidebar').on('click', 'a', function() {
  34 + // 拦截跳转
  35 + interceptClick($(this).attr('href'));
  36 + return false;
  37 + });
34 } 38 }
35 }; 39 };
36 </script> 40 </script>
@@ -100,8 +100,9 @@ @@ -100,8 +100,9 @@
100 this.contentCode = contentCode[page][channel]; 100 this.contentCode = contentCode[page][channel];
101 }); 101 });
102 }, 102 },
103 - attached() { 103 + ready() {
104 $('.resources').on('click', 'a', function() { 104 $('.resources').on('click', 'a', function() {
  105 + // 拦截跳转
105 interceptClick($(this).attr('href')); 106 interceptClick($(this).attr('href'));
106 return false; 107 return false;
107 }); 108 });