Waxy主题开启全站Pjax
|
字数总计:
2172
|
阅读时长:
1分钟
|
阅读量:
31998
这篇文章距离最后更新已过580 天,如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
- 修改.php文件
- 进入Waxy主题根目录,找到
header.php和footer.php,进行如下修改

<body class="home-template">
<div id="pjax-container">

<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.pjax/2.0.1/jquery.pjax.min.js"></script>
<script Type="text/javascript">
(function($){
var MyApp = {
initPjax: function(){
var self = this;
// 初始化
$(document).pjax('a[target!="_blank"]', '#pjax-container', {
fragment: "#pjax-container",
timeout: 5000
});
// pjax请求开始
$(document).on('pjax:start', function () {
});
// PJAX 渲染结束时
$(document).on('pjax:end', function() {
comments();
self.siteBootUp();
//在「局部刷新」时才会运行
console.log("局部执行");
if (typeof Prism !== 'undefined') {
var pres = document.getElementsByTagName('pre');
for (var i = 0; i < pres.length; i++){
if (pres[i].getElementsByTagName('code').length > 0)
pres[i].className = 'line-numbers';}
Prism.highlightAll(true,null);}
});
self.siteBootUp();
},
/*
* Things to be execute when normal page load
* and pjax page load.
*/
siteBootUp: function(){
//「局部刷新」和「页面刷新」都需要运行的代码
console.log("全局执行");
}
};
window.MyApp = MyApp;
})(jQuery);
//「页面刷新」事件触发运行
$(document).ready(function() {
MyApp.initPjax();
});
</script>
- 重点来了,目前已知bug:
YoDuPlayer点击无反应;
部分图片会以缩略图显示,即使后台关了懒加载也一样。
我也想做一个优雅的淑女,是生活把老娘逼成了泼妇。
你得好好努力,才能配得上,被人利用。
啦啦啦
:arrow: