Newer
Older
KaiFengWechat / src / utils / main.js
@鲁yixuan 鲁yixuan on 12 Jul 1 KB update
// 兼容处理
import './compatible';

import { createApp } from 'vue';
import App from '@/App.vue';
import router from '@/router/index';
import '@/assets/less/style.less';
import 'vant/es/toast/style';
import 'animate.css/animate.min.css';
// pinia状态管理
import { createPinia } from 'pinia';
import { showSuccessToast, showFailToast } from 'vant';

// vant4样式引入
import 'vant/es/toast/style';
import 'vant/es/dialog/style';
import 'vant/es/notify/style';
import 'vant/es/image-preview/style';

// 持久化存储pinia
import piniaPluginPersist from 'pinia-plugin-persist';
const pinia = createPinia();
pinia.use(piniaPluginPersist);

const appXF = createApp(App);

// 全局方法
appXF.config.globalProperties.showSuccessToast = showSuccessToast; //toast成功提示
appXF.config.globalProperties.showFailToast = showFailToast; //toast失败提示

// import VConsole from 'vconsole';
// let vConsole = new VConsole();
// appXF.use(vConsole);

// 错误打印
appXF.config.errorHandler = (err, instance, info) => {
  // 处理错误,例如:报告给一个服务
  console.log('全局异常--', err, instance, info);
};

appXF.use(router).use(pinia).mount('#xfApp');