From 4f55badfaa33784bf6c4a69ac41db1d67c5be6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 3 Mar 2020 21:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/question/Questionitem_banks.js | 20 ++++++++++++++++++- public/react/src/modules/tpm/NewHeader.js | 7 +++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index d82e0e52f..84d1a7e47 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -1,5 +1,5 @@ import React, {Component} from "react"; -import {Link, NavLink} from 'react-router-dom'; +import {Link, NavLink,Prompt} from 'react-router-dom'; import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl,queryString} from 'educoder'; import axios from 'axios'; import { Breadcrumb } from "antd"; @@ -163,6 +163,20 @@ class Questionitem_banks extends Component { } + componentWillMount () { + // 拦截判断是否离开当前页面 + window.addEventListener('beforeunload', this.beforeunload); + } + componentWillUnmount () { + // 销毁拦截判断是否离开当前页面 + window.removeEventListener('beforeunload', this.beforeunload); + } + beforeunload (e) { + let confirmationMessage = '你确定离开此页面吗?'; + (e || window.event).returnValue = confirmationMessage; + return confirmationMessage; + } + getdata = (data) => { // const url=`/item_banks.json`; @@ -501,6 +515,10 @@ class Questionitem_banks extends Component {