【发布时间】:2019-04-08 14:10:42
【问题描述】:
我找到了一个可以在next.js 上平滑滚动的脚本。
这里是回购: https://gist.github.com/vinaypuppal/b7271ad84a0d69c9cfafaaa83afed199
我添加了所有必需的内容,并添加了第一条评论建议的更改。但还是和使用react/link一样。
问题是它甚至没有调用这段代码:
//#LinkSmoothScroll.js
//...
linkClicked(e) {
e.preventDefault()
Router
.push(this.props.href)
.then(() => {
console.log('test') //this one is not being called at all when I click the <LinkSmoothScroll>
return smoothScroll(this.props.href)
})
.then(() => {
this.props.done && this.props.done()
})
.catch(err => {
this.props.onError && this.props.onError(err)
console.error(err)
})
}
//...
【问题讨论】: