Skip to content

Commit cde982d

Browse files
committed
debug: set title
1 parent 4fe46b3 commit cde982d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

dist/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
var setTitle = function setTitle() {
22
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
3+
var debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
34

45
// 验证参数
56
if (title instanceof String) {
67
return;
78
}
89
// 设置标题
910
document.title = title;
11+
// 开启debug
12+
// 在开发者模式下创建iframe会造成多次重绘
13+
// 不建议关闭
14+
if (debug) {
15+
return;
16+
}
1017
// 兼容ios
1118
var $iframe = document.createElement('iframe');
1219
// set attribute
@@ -292,7 +299,9 @@ var install = function install(Vue) {
292299
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
293300

294301
// 获取配置
295-
var router = options.router,
302+
var _options$debug = options.debug,
303+
debug = _options$debug === undefined ? true : _options$debug,
304+
router = options.router,
296305
store = options.store,
297306
_options$title = options.title,
298307
title = _options$title === undefined ? false : _options$title,
@@ -357,7 +366,7 @@ var install = function install(Vue) {
357366
var _to$meta$title = to.meta.title,
358367
toTitle = _to$meta$title === undefined ? null : _to$meta$title;
359368

360-
setTitle(toTitle);
369+
setTitle(toTitle, debug);
361370
}
362371
// 调起钩子函数
363372
after(r);

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let hook = function () {}
2626
const install = function (Vue, options = {}) {
2727
// 获取配置
2828
const {
29+
debug = true,
2930
router,
3031
store,
3132
title = false,
@@ -73,7 +74,7 @@ const install = function (Vue, options = {}) {
7374
// 进行标题处理
7475
if (title) {
7576
const {title: toTitle = null} = to.meta
76-
setTitle(toTitle)
77+
setTitle(toTitle, debug)
7778
}
7879
// 调起钩子函数
7980
after(r)

src/utils/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11

2-
export const setTitle = function (title = null) {
2+
export const setTitle = function (title = null, debug = true) {
33
// 验证参数
44
if (title instanceof String) {
55
return
66
}
77
// 设置标题
88
document.title = title
9+
// 开启debug
10+
// 在开发者模式下创建iframe会造成多次重绘
11+
// 不建议关闭
12+
if (debug) {
13+
return
14+
}
915
// 兼容ios
1016
const $iframe = document.createElement('iframe')
1117
// set attribute

0 commit comments

Comments
 (0)