加载 plugins=vue-report 后,Vue 的异常与开发环境告警会上报一条 head=vue,在通道管理里面新增飞书、钉钉、企业微信、邮件推送通道。
加载中…
WebsitePusher.init({
appName: "vue 上报示例",
channelCode: "你的通道码",
hideDialog: 1,
plugins: "vue-report",
vueReportMax: 10, // 本页最多上报条数,默认 10
vueReportWarn: 1 // 0=不上报警告,只报 errorHandler
});
Vue2 接管全局 Vue.config;Vue3/4 包装 Vue.createApp,所以要在插件接管之后再 createApp(本页按钮每次点击都新建 app)。
正在等待插件接管 Vue…
日志里 head=vue 的 body 就是上报内容(示例只截前 160 字符)。插件不吞异常:宿主原有的 errorHandler / warnHandler 仍会被链式调用。
| 参数 | 默认 | 说明 |
|---|---|---|
vueReportMax | 10 | 本页最多上报条数;<=0 表示不上报。达到上限后只 console.warn。 |
vueReportWarn | 1 | 0=不接管 warnHandler,只上报真正的异常。 |
同一异常本页只报一次;body 超长会按 stack → info → message 的顺序瘦身,尽量保持合法 JSON;插件不写 Cookie/localStorage。