From bb96e00b7839c6fd0402e532f0a9a1f01c1c7228 Mon Sep 17 00:00:00 2001 From: ccbikai <ccbikai@qq.com> Date: Wed, 27 Jul 2016 12:10:41 +0800 Subject: [PATCH] 拦截跳转 --- public/js/common/intercept-click.js | 16 ++++++++++++++++ public/vue/component/resources/index.vue | 7 +++++++ 2 files changed, 23 insertions(+), 0 deletions(-) create mode 100644 public/js/common/intercept-click.js diff --git a/public/js/common/intercept-click.js b/public/js/common/intercept-click.js new file mode 100644 index 0000000..937ea4d --- /dev/null +++ b/public/js/common/intercept-click.js @@ -0,0 +1,16 @@ +/** + * 拦截跳转, 在这里给将要打开的页面设置一下 header 样式 + * @return {[type]} + */ +const yoho = require('yoho'); + +module.exports = (url) => { + console.log(url); + if (yoho.isApp) { + yoho.goNewPage({ + url: url + }); + } else { + location.href = url; + } +}; diff --git a/public/vue/component/resources/index.vue b/public/vue/component/resources/index.vue index f60c357..a3d97fa 100644 --- a/public/vue/component/resources/index.vue +++ b/public/vue/component/resources/index.vue @@ -27,6 +27,7 @@ const $ = require('yoho-jquery'); const tip = require('common/tip'); const bus = require('common/vue-bus'); + const interceptClick = require('common/intercept-click'); const contentCode = require('content-code'); const focus = require('./focus.vue'); @@ -98,6 +99,12 @@ bus.$on('channel.change', (page, channel) => { this.contentCode = contentCode[page][channel]; }); + }, + attached() { + $('.resources').on('click', 'a', function() { + interceptClick($(this).attr('href')); + return false; + }); } }; </script> -- libgit2 0.24.0