Skip to content

Commit

Permalink
适配2.0版本
Browse files Browse the repository at this point in the history
  • Loading branch information
deboyblog committed Jan 6, 2017
1 parent 04e528e commit 307668c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
Vuejs 单页应用在iOS的微信webview(或者其他APP)中 标题不能通过 document.title = xxx 的方式修改
该插件只为解决该问题而生

### 效果 (请使用微信扫描打开体验)
### 效果 (请使用微信扫描打开体验) Vuejs1.x实现

![预览](./preview.png)

直接打开: [http://vue-wechat-title.deboy.cn/](http://vue-wechat-title.deboy.cn/)

### 安装

> 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)
Expand All @@ -26,8 +34,7 @@ Vue.use(require('vue-wechat-title'))
> App.vue **建议全局只使用一次该指令 标题可用wuex或者router中定义 不要多处使用!!**
```html
<router-view v-wechat-title="$route.title || 'your-title'"></router-view>
<!-- 或者任意元素中加 v-wechat-title 指令 建议将标题放在 route 的定义中 -->
<!-- 任意元素中加 v-wechat-title 指令 建议将标题放在 route 的定义中 -->
<div v-wechat-title="$route.title || 'your-title'"></div>
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-wechat-title",
"version": "1.0.6",
"version": "2.0.0",
"description": "给Vuejs单页应用添加在微信页面中动态设置网页标题功能的指令",
"main": "vue-wechat-title.js",
"scripts": {
Expand Down
9 changes: 2 additions & 7 deletions vue-wechat-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit 307668c

Please sign in to comment.