去除vue中相关警告语

1.SweetAlert2插件警告

SweetAlert2: “setDefaults” & “resetDefaults” methods are deprecated in favor of “mixin” method and will be removed in the next major release. For new projects, use “mixin”. For past projects already using “setDefaults”, support will be provided through an additional package.

大致意思:SweetAlert2插件中的setDefaults方法过期,使用mixin方法即可,如下:

import swal from 'sweetalert2';
export default {
  install: (Vue) => {
    // sweetalert2 的设置默认配置的方法
    swal.mixin({
      //type: 'warning',
      showCancelButton: true,
      cancelButtonText:'取消',
      confirmButtonText:'确认',
      confirmButtonColor: 'rgb(140,212,245)',       
      cancelButtonColor: 'rgb(193,193,193)'

    });
    // 添加全局方法
    Vue.swal = swal;
    // 添加实例方法
    Vue.prototype.$swal = swal;

  }
}

详细介绍可以查看官方文档:
相关链接: https://sweetalert2.github.io/#examples.

2.百度api插件警告:

parser-blocking, cross site (i.e. different eTLD+1) script, http://api.map.baidu.com/getscript?v=3.0&ak=EfW7687887888888464h&services=&t=20676767676, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.

将引用中的api换成getscript即可,如下:

原链接:
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=5464546456464645654Alh"></script>
修改后链接:
<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=3.0&ak=5464546456464645654Alh"></script>
3.路由报错警告
解决路由设置报错
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

路由异步报错
Component “default” in record with path “/login” is a Promise instead of a function that returns a Promise

component:  () =>import("@/views/XX.vue")
过滤某些警告

注意:仅对浏览器的控制层处理

1、过滤url(以下前缀+http地址)
-url:

具体参考细节:

浏览器控制台过滤无用的提示和报错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值