Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开启PJAX局部刷新后,文章和页面中的短代码无法解析,需手动刷新 #285

Open
Starlwr opened this issue Jan 15, 2022 · 5 comments

Comments

@Starlwr
Copy link

Starlwr commented Jan 15, 2022

问题描述

安装短代码插件(Shortcoder),并开启PJAX局部刷新后,从首页点开页面或文章,其中的短代码无法解析,效果如下
短代码刷新前
手动刷新后才可以正常显示,效果如下
短代码刷新后
图片中是引入了一个element-ui的测试按钮,在插件中新建短代码,名称为element-button,添加以下代码后保存,即可在文章或页面中使用[sc name="element-button"][/sc]引入

<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
	<el-button @click="visible = true">Button</el-button>
	<el-dialog :visible.sync="visible" title="Hello world">
		<p>test</p>
	</el-dialog>
</div>
<script>
	new Vue({
		el: '#app',
		data: function() {
			return { visible: false }
		}
	})
</script>
@mashirozx
Copy link
Owner

需要把相关代码放进重载函数里面,见app.js

@Starlwr
Copy link
Author

Starlwr commented Jan 16, 2022

看了一下sakura-app.js,但是没太搞明白,是需要把解析短代码相关的函数放在this.pjax = function () 里面吗,如果您知道如何操作的话可否稍微再指点一下

@mashirozx
Copy link
Owner

对的,放里面

@smallsay
Copy link

有无简单的示例?比如就 console.log("每个页面都运行这句") 让每个页面在控制台都输出

@mashirozx
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants