Newer
Older
KaiFengH5 / src / utils / main.js
@zhangdeliang zhangdeliang on 24 May 1 KB 项目初始化
// 兼容处理
import './compatible';

import { createApp } from 'vue';
import App from '@/App.vue';
import router from '@/router/index';
import '@/assets/less/style.less';
import 'animate.css/animate.min.css';

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

// pinia状态管理
import { createPinia } from 'pinia';
import { showSuccessToast, showFailToast } from 'vant';

// 持久化存储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');