跳转到内容
English

@mitojs/vue

旧版指南保留了早期 SDK 的接入方式。v4 需要支持 ES2015 的运行环境,并已结束对 Internet Explorer 的支持。 查看 v4 快速入门

两套示例都使用 MitoJS 4.0.0;上报在当前浏览器接收,不发送给生产监控。

如果你想要在微信小程序里面引入,请把 @mitojs/browser 替换成 @miotjs/wx-mini

终端窗口
# using npm
npm i @mitojs/vue @mitojs/browser
# using yarn
yarn add @mitojs/vue @mitojs/browser
// main.js
import Vue from 'vue'
import { init } from '@mitojs/browser'
import { vuePlugin } from '@mitojs/vue'
// multiple instances
const MitoInstance = init({
vue: Vue,
dsn: 'https://test.com/yourInterface',
maxBreadcrumbs: 100
},[vuePlugin])
// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import { init } from "@mitojs/browser";
import { vuePlugin } from "@mitojs/vue";
const app = createApp(App)
const MitoInstance = init({
vue: app,
dsn: 'https://test.com/yourInterface',
maxBreadcrumbs: 100
},[vuePlugin])

不推荐使用CDN方式,因为@mitojs/web的cjs文件包含了jsxRuntime代码,所以这个包的大小会比其他的包大很多。

index.html

<header>
<script src="https://cdn.jsdelivr.net/npm/@mitojs/web/dist/web.min.js"></script>
</header>

当你在index.html使用了CDN方式,将会有一个MITO的全局变量会被挂载到window上。然后你就可以在组件中使用它

index.js

import Vue from 'vue'
const MitoInstance = MITO.init({
dsn: 'https://test.com/yourServer',
maxBreadcrumbs: 100,
vue:Vue
},[MITO.vuePlugin])