-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
页面与ant锚点组件的问题 #287
Comments
用hash模式, 就不用锚点, 这是共识 |
有没有办法实现这样的功能, |
用history模式. |
拍脑袋想到两个方案:
|
@sorrycc 请问第一个方案的话在哪里修改呢? |
感激! 试下第二个方案 |
这篇文章,值得学习!感觉有些地方DVA用的是ES7的写法,比如Dump Component,ES6跟ES7搞得很混淆。。
|
@marsDes 问题是否解决? |
先close了 |
不好意思,刚看到 看到issues有相关的,我先看一遍先 |
用history模式, 需要服务器或者后端的支持... |
使用模拟锚点的形式完成锚点定位,不要直接使用href=#anchor的形式,需要拼接完整的地址url,在IE9下面也兼容,我是vue-router,原理是一样的,你看看。 toAnchor(anchor){
const url = document.location.href.split('#');
this.$router.push(`${url[1]}#${anchor}`);
} beforeRouteUpdate(to, from, next){
if (to.hash !== '') {
const id = to.hash.replace('#', '');
const element = document.getElementById(id);
// 定位到锚点
if (element) element.scrollIntoView();
}
next();
} |
http://localhost:8989/#/flightstatus?_k=gopn9y
在这个页面有个锚点 id="A" 触发后
地址栏的url会变成http://localhost:8989/#A
会导致页面刷新的时候报错
有人遇到这个问题吗?
The text was updated successfully, but these errors were encountered: