作者:潇洒D-An_na | 来源:互联网 | 2023-08-27 18:10
demo: http://output.jsbin.com/foziyafiti
In my macOS Safari 10.0.1, it doesn't scroll smoothly.
I find that
1
| document.querySelector('#中文2') |
is OK but
1
| document.querySelector('a[href="#中文2"]').hash |
returns
,and
1
| document.querySelector(document.querySelector('a[href="#中文2"]').hash) |
makes an error. Maybe something hacks needed in Safari I guess.
Thanks.
该提问来源于开源项目:cferdinandi/smooth-scroll
Fixed: https://github.com/cferdinandi/smooth-scroll/pull/307
Working demo: https://jsfiddle.net/cferdinandi/w190zrax/