240
世界上有2种人,一种懂二进制,另一种不懂二进制。

vue--总结

import

export

export deflut{

components: { ComponentA, ComponentC}//组件注册

各种内容

}

https://blog.csdn.net/u014635374/article/details/118761130

https://www.cnblogs.com/lsc-boke/p/11007879.html    vue引入全局组件和局部组件的区别以及全局注册公共函数

各种方法

2个入口


入口1、src/main.js:入口文件,1、主要作用是初始化vue实例,2、在此文件中引用某些组件库3、全局挂载一些变量

//2、在此文件中引用某些组件库
import
{ createApp } from 'vue' import App from './App.vue' import router from './router' import store from './store' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import * as ElementPlusIconsVue from '@element-plus/icons-vue' //1、主要作用是初始化vue实例 const app = createApp(App) for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component)//组件注册

}
//3、全局挂载一些变量(例如刚刚引用的组件变量)
app.use(store).use(router).use(ElementPlus).mount('#app')

入口2、src/App.vue:主vue模块 引入其他模块,app.vue是项目的主组件,所有页面都是在app.vue下切换的

<template>
  <el-config-provider :locale="locale">
    <router-view />
  </el-config-provider>
</template>
<script>
import { ref, provide } from "vue";
import * as echarts from "echarts";
import mitt from "mitt";
import { ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'

export default {
  components: {
    [ElConfigProvider.name]: ElConfigProvider,
  },
  setup() {
    let locale = ref(zhCn)   //配置elementplus为中文显示
    const emitter = mitt();
    provide("emitter", emitter); //emitter挂载到全局  事件车
    provide("echarts", echarts); //echarts挂载到全局
    return {
      locale
    }
  },
};
1个全局的路由信息表  
    src/router.js:路由文件,1、这个里边可以理解为各个页面的地址路径,用于我们访问,2、同时可以直接在里边编写路由守卫
<router-view />就要用到全局的路由里的routes

 

 

路由守卫:https://blog.csdn.net/weixin_55225560/article/details/120639897
路由守卫的理解与用法:https://blog.csdn.net/weixin_56115652/article/details/123021080

8种通信方式

    eventBus       provide/ inject    ref / refs     props / $emit $children / $parent

参考如下:

https://www.jianshu.com/p/768e002dbe92

https://zhuanlan.zhihu.com/p/443845528

https://www.cnblogs.com/benbonben/p/14958025.html

https://www.cnblogs.com/benbonben/p/14958439.html

 






posted @ 2022-06-17 17:27  _Origin  阅读(118)  评论(0)    收藏  举报