站内搜索:
首页 >> 前端 >> 内容
怎样实现判断当前页面是否修改内容,并在离开页面的时候给出提示?

时间:2018/4/23 15:04:56

怎样实现判断当前页面是否修改内容,并在离开页面的时候给出提示?

let _this=this;
window.onbeforeunload = function() {
  let nowOrderVo=JSON.stringify(_this.orderVo);
  if (_this.copyOrderVo!==nowOrderVo) {
    try {
      return "当前修改尚未保存,是否离开?";
    } catch (err) {}
  }
};

  • 上一篇:在一个项目中,怎样判断数组和对象?
  • 下一篇:vue-cli怎么设置网页左上角icon图标?
  • 返回顶部