Anchor Props Link Props 自定义 onClick 事件 点击锚点不记录历史。 TypeScript JavaScript import { Anchor } from 'antd'; import React from 'react'; const { Link } = Anchor; const handleClick = ( e: React.MouseEvent<HTMLElement>, link: { title: React.ReactNode; href: string; }, ) =>...
AnchorItem 参数说明类型默认值版本 key唯一标志string | number- href锚点链接string- target该属性指定在何处显示链接的资源string- title文字内容ReactNode- children嵌套的 Anchor Link,注意:水平方向该属性不支持AnchorItem[]- replace替换浏览器历史记录中的项目 href 而不是推送它booleanfalse5.7.0 ...
-- 左边菜单区 --> <a-anchor :affix="false" :get-current-anchor="getCurrentAnchor"> <!-- 一级锚点 --> <a-anchor-link href="#menu1" title="菜单一"> <!-- 二级锚点 --> <a-anchor-link href="#menu2" title="菜单二" /> </a-anchor-link> </a-anchor> <!-- 右边内容滚动区 ...
const handleClick: AnchorProps['onClick'] = (e, link) => { e.preventDefault(); console.log(link, 'link'); console.log(getContainer, 'getContainer'); if (link.href) { // 找到锚点对应得的节点 let element = document.getElementById(link.href.replace('#', '')) console.log('element',...
Link Props Listening for anchor link change Listening for anchor link change. TS TS TS TS API# # Anchor Props# PropertyDescriptionTypeDefaultVersion affixFixed mode of Anchorbooleantrue boundsBounding distance of anchor areanumber5(px) getContainerScrolling container() => HTMLElement() => window ...
targetOffsetAnchor scroll offset, default asoffsetTop,examplenumber- onChangeListening for anchor link change(currentActiveLink: string) => void onClickSet the handler to handleclickevent(e: MouseEvent, link: object) => void- itemsData configuration option content, support nesting through children{ ...
export default class BaseAnchor extends Component { constructor(props) { super(props); this.state = {}; } render() { const { anchors = [], //锚点数组,link-节点id,title-显示文字 content, //左侧内容 ...restProps } = this.props; ...
title文字内容VueNode | (item: AnchorItem) => VueNode- children嵌套的 Anchor Link,注意:水平方向该属性不支持AnchorItem[]- 事件# 事件名称说明回调参数版本 change监听锚点链接改变(currentActiveLink: string) => void1.5.0 clickclick事件的 handlerFunction(e: MouseEvent, link: Object) ...
import{Anchor}from'antd'; const{Link} =Anchor; ReactDOM.render( <Anchor> <Linkhref="#components-anchor-demo-basic"title="Basic demo"/> <Linkhref="#components-anchor-demo-static"title="Static demo"/> <Linkhref="#components-anchor-demo-basic"title="Basic demo with Target"target="_blank"/...
Link Props Listening for anchor link change Listening for anchor link change. TS TS TS TS API# # Anchor Props# PropertyDescriptionTypeDefaultVersion affixFixed mode of Anchorbooleantrue boundsBounding distance of anchor areanumber5(px) getContainerScrolling container() => HTMLElement() => window ...