搜索文档
注意:所有的全局配置一定要在 app.mount 之前,否在出不来效果。
全局数据
Vue2
jsVue.prototype.$tool = tool;Vue3
jsapp.config.globalProperties.$tool = tool;组件中使用:
jsmport { getCurrentInstance } from "vue"; getCurrentInstance().proxy.xxx
全局组件
Vue2
jsVue.component('Home', () => import('./components/Home'));Vue3
jsconst app = createApp(App) app.component('Home', defineAsyncComponent(() => import('./components/Home.vue'))); app.mount('#app');
全局中间件
Vue2
jsVue.use(VueRouter);Vue3
jsapp.use(VueRouter);
