Skip to content

Commit e61540a

Browse files
authored
Merge pull request #58 from Lohoyo/master
fix: 修复文档示例代码的高亮偶尔失效的问题
2 parents 6262f9f + 3fed2f5 commit e61540a

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

site/src/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ class Index extends Component {
208208
that.handleError(e);
209209
});
210210
}
211-
that.hlCode();
212211
}
213212

214213
// 完成加载进度条
@@ -265,16 +264,12 @@ class Index extends Component {
265264
}
266265

267266
document.title = `${title} - ${titleSuffix}`;
267+
this.hlCode();
268268
});
269269
}
270270

271271
hlCode() {
272-
setTimeout(() => {
273-
let code = document.getElementsByTagName('code');
274-
Array.prototype.forEach.call(code, function (item) {
275-
Prism.highlightElement(item);
276-
});
277-
}, 500);
272+
Array.prototype.forEach.call(document.getElementsByTagName('code'), item => Prism.highlightElement(item));
278273
}
279274
handleError(err) {
280275
Notification.error({

0 commit comments

Comments
 (0)