Merge pull request #2018 from 2betop/page

data-link 优化
This commit is contained in:
RickCole 2021-05-26 10:52:05 +08:00 committed by GitHub
commit 3070bf889f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -348,9 +348,13 @@ export default class Page extends React.Component<PageProps> {
handleClick(e: any) {
const target: HTMLElement = e.target as HTMLElement;
const {env} = this.props;
const link =
target.tagName === 'A' && target.hasAttribute('data-link')
? target.getAttribute('data-link')
: target.closest('a[data-link]')?.getAttribute('data-link');
if (env && target.tagName === 'A' && target.hasAttribute('data-link')) {
env.jumpTo(target.getAttribute('data-link') as string);
if (env && link) {
env.jumpTo(link);
e.preventDefault();
}
}