Open andyChenAn opened 5 years ago
给Router
组件传getUserConfirmation
的props
来自定义拦截
const getConfirmation = (message, callback) => {
Modal.confirm({
title: message,
onCancel: () => {
callback(false);
},
onOk: () => {
callback(true);
}
});
}
<BrowserRouter getUserConfirmation={getConfirmation} >
<App />
</BrowserRouter>
s
来自定义拦截
多谢提醒
react路由组件之Prompt组件
Prompt组件主要用于在用户离开页面之前提醒用户。当
Prompt组件有以下几个属性:
上面代码就是一个简单的Prompt组件使用的例子,当我们在输入框输入东西时,然后点击链接,就会渲染Prompt组件,如果点击确定,那么会跳转,如果点击取消那么就不会跳转。