Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

「常见问题」遗漏配置中的页面标识相关字段,导致评论无法刷新 #4

Closed
dolyw opened this issue Nov 18, 2019 · 14 comments
Labels
done Answered, fixed, finished. question Further information is requested

Comments

@dolyw
Copy link

dolyw commented Nov 18, 2019

如题,VuePress页面切换不会重新加载Valine的评论的,导致评论一直是第一个页面的

@dongyuanxin
Copy link
Owner

@dolyw 是否是最新版本?提供一下用法例子或者仓库地址。

@dolyw
Copy link
Author

dolyw commented Nov 19, 2019

我看其他人是自己写了一个自定义组件进行watch监听路由是否变化去刷新评论的

@dolyw
Copy link
Author

dolyw commented Nov 19, 2019

@dongyuanxin dongyuanxin added the bug Something isn't working label Nov 19, 2019
@dongyuanxin
Copy link
Owner

dongyuanxin commented Nov 19, 2019

@dolyw
都是安装的最新版本

A:问题已经排查,插件没有问题。

我看其他人是自己写了一个自定义组件进行watch监听路由是否变化去刷新评论的

A: 插件自带路由监听,并且针对渲染、防抖和加载做了各种优化

VuePress页面切换不会重新加载Valine的评论的,导致评论一直是第一个页面的

A: 问题出现出现在 /doc/.vuepress/config.js插件的配置没有指明path字段。请参考vuepress-plugin-comment#vue-in-valine

@dongyuanxin dongyuanxin added question Further information is requested and removed bug Something isn't working labels Nov 19, 2019
@dongyuanxin dongyuanxin changed the title 页面路由切换不会刷新Valine的评论 「常见问题」遗漏配置中的页面id标识字段,导致评论无法刷新 Nov 19, 2019
@dongyuanxin dongyuanxin changed the title 「常见问题」遗漏配置中的页面id标识字段,导致评论无法刷新 「常见问题」遗漏配置中的页面标识相关字段,导致评论无法刷新 Nov 19, 2019
@dolyw
Copy link
Author

dolyw commented Nov 19, 2019

image
这样还是不行,直接获取路径,我不想每个文章都去加参数

@dongyuanxin
Copy link
Owner

@dolyw
这样还是不行,直接获取路径,我不想每个文章都去加参数

换成:'<%- frontmatter.to.path %>' 即可。在vuepress中,window上的路由对象拿到的信息不一定是正确的,插件自动给frontmatter变量注册了fromto对象,请在其上获取路由信息。

@dolyw
Copy link
Author

dolyw commented Nov 19, 2019

解决了,谢谢

@dolyw dolyw closed this as completed Nov 19, 2019
@dongyuanxin dongyuanxin reopened this Nov 20, 2019
@dongyuanxin
Copy link
Owner

dongyuanxin commented Nov 20, 2019

@dolyw
解决了,谢谢

Reopen for other people

@dongyuanxin dongyuanxin added the done Answered, fixed, finished. label Nov 20, 2019
@yinxin630
Copy link

我有 base 配置, 设置成 <%- frontmatter.to.path %> 不行, 不包含 base 路径, 这种情况该怎么办

@yinxin630
Copy link

我有 base 配置, 设置成 <%- frontmatter.to.path %> 不行, 不包含 base 路径, 这种情况该怎么办

我找到一个解决办法, 配置成 <%- frontmatter.to.path ? "/base" + frontmatter.to.path : window.location.pathname %> 即可

@kaizige10
Copy link

@dolyw
这样还是不行,直接获取路径,我不想每个文章都去加参数

换成:'<%- frontmatter.to.path %>' 即可。在vuepress中,window上的路由对象拿到的信息不一定是正确的,插件自动给frontmatter变量注册了fromto对象,请在其上获取路由信息。

按照这个方法确实解决了,赞~

@yiliang114
Copy link
Contributor

如果想统计每一个页面的请求量,path 设置了 <%- frontmatter.to.path %> 这个会让除了首次访问以外,切换路由之后的访问量都为 0

@ajunxu
Copy link

ajunxu commented Mar 4, 2021

@dolyw
这样还是不行,直接获取路径,我不想每个文章都去加参数

换成:'<%- frontmatter.to.path %>' 即可。在vuepress中,window上的路由对象拿到的信息不一定是正确的,插件自动给frontmatter变量注册了fromto对象,请在其上获取路由信息。

配置成'<%- frontmatter.to.path %>' 这样,但是页面刷新,评论就消失了,要切换到下一页,再切换回上一页,评论才出现,所以path要怎么设置

@swhmonster
Copy link

禁用评论,无效果,配置comments: false

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
done Answered, fixed, finished. question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants