-
Ellipsis组件在Link下点击展开如何阻止跳转页面
但是不知道怎么使用 有大佬教教么
|
Beta Was this translation helpful? Give feedback.
Answered by
xiaoyao96
Jun 23, 2022
Replies: 4 comments 7 replies
-
<>
<Link to="/">
<Ellipsis
onContentClick={(e) => e.preventDefault()}
direction="end"
content={content}
expandText="展开"
collapseText="收起"
/>
</Link>
</> 这个应该能实现,但是你这么写似乎有点奇怪 |
Beta Was this translation helpful? Give feedback.
2 replies
-
奇怪,按理说这样就可以了: <Link to="/">
<Ellipsis
direction="end"
content={content}
expandText="展开"
collapseText="收起"
stopPropagationForActionButtons={["click"]}
/>
</Link> 但是我试了一下确实不行 |
Beta Was this translation helpful? Give feedback.
1 reply
-
如果想要内容可跳转,展开/收起按钮不能跳转。应该这样: import React from "react";
import { Ellipsis } from "antd-mobile";
import { Link, useNavigate } from "react-router-dom";
const content =
"蚂蚁的企业级产品是一个庞大且复杂的体系。这类产品不仅量级巨大且功能复杂,而且变动和并发频繁,常常需要设计与开发能够快速的做出响应。同时这类产品中有存在很多类似的页面以及组件,可以通过抽象得到一些稳定且高复用性的内容。";
export default () => {
let navigate = useNavigate();
return (
<>
<Link
to="/"
onClick={(e) => {
e.preventDefault();
navigate("/");
}}
>
<Ellipsis
direction="end"
content={content}
expandText="展开"
collapseText="收起"
stopPropagationForActionButtons={["click"]}
/>
</Link>
</>
);
}; ------ 后续更新 ------- |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
awmleer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果想要内容可跳转,展开/收起按钮不能跳转。应该这样: