From 307668c5f9820f014307429cd836f7c3be531419 Mon Sep 17 00:00:00 2001 From: Deboy <55631825@qq.com> Date: Fri, 6 Jan 2017 14:24:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D2.0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 +++++++++++---- package.json | 2 +- vue-wechat-title.js | 9 ++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 964f859..b00540c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Vuejs 单页应用在iOS的微信webview(或者其他APP)中 标题不能通过 document.title = xxx 的方式修改 该插件只为解决该问题而生 -### 效果 (请使用微信扫描打开体验) +### 效果 (请使用微信扫描打开体验) Vuejs1.x实现 ![预览](./preview.png) @@ -10,8 +10,16 @@ Vuejs 单页应用在iOS的微信webview(或者其他APP)中 标题不能通过 ### 安装 +> Vuejs 1.x + +```bash +npm install vue-wechat-title@1.0.6 --save +``` + +> Vuejs 2.x + ```bash -npm install vue-wechat-title --save +npm install vue-wechat-title@2.0.0 --save ``` ### 用法 [demo](https://github.com/deboyblog/vue-wechat-title-demo/tree/use-directive) @@ -26,8 +34,7 @@ Vue.use(require('vue-wechat-title')) > App.vue **建议全局只使用一次该指令 标题可用wuex或者router中定义 不要多处使用!!** ```html - - +
``` diff --git a/package.json b/package.json index f56ea16..080ee1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-wechat-title", - "version": "1.0.6", + "version": "2.0.0", "description": "给Vuejs单页应用添加在微信页面中动态设置网页标题功能的指令", "main": "vue-wechat-title.js", "scripts": { diff --git a/vue-wechat-title.js b/vue-wechat-title.js index 66a386f..22dd4b4 100644 --- a/vue-wechat-title.js +++ b/vue-wechat-title.js @@ -21,13 +21,8 @@ document.body.appendChild(iframe) } } - Vue.directive('wechat-title', { - bind: function (title) { - setWechatTitle(title) - }, - update: function (newTitle) { - setWechatTitle(newTitle) - } + Vue.directive('wechat-title', function (el, binding) { + setWechatTitle(binding.value) }) }