当前位置: 首页 > news >正文

小榄网站建设郑州网络推广排名

小榄网站建设,郑州网络推广排名,阿里云ecs 怎么做网站,北斗手表官方网站因为我们要根据路由配置对应的图标,也要为了后续方便更改。因此我们将所有的图标注册为全局组件。(使用之前将分页器以及矢量图注册全局组件的自定义插件)(所有图标全局注册的方法element-plus文档中已给出) 全局注册…

因为我们要根据路由配置对应的图标,也要为了后续方便更改。因此我们将所有的图标注册为全局组件。(使用之前将分页器以及矢量图注册全局组件的自定义插件)(所有图标全局注册的方法element-plus文档中已给出)

全局注册elementPlus图标

在这里插入图片描述
经过上面的步骤,就可以把elementPlus自带的icon图标全局注册了。

路由使用elementPlus图标

给路由元信息添加属性:icon
layout和其子组件为例:首先在element-puls找到你要使用的图标的名字。将它添加到路由元信息的icon属性上

{//登录成功以后展示数据的路由path: '/',component: () => import('@/layout/index.vue'),name: 'layout',meta: {title: 'layout',hidden: false,icon: 'Avatar',//elementPlus中的图标},children: [{path: '/home',component: () => import('@/views/home/index.vue'),meta: {title: '首页',hidden: false,icon: 'HomeFilled',//elementPlus中的图标},},],
},

外部引入的svg图标——vite.config.js中批量引入

在这里插入图片描述

import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
export default defineConfig(({command,mode})=>{const env = loadEnv(mode,process.cwd())return {plugins:[vue(),AutoImport({resolvers: [ElementPlusResolver(),IconsResolver({prefix: 'Icon',}),],}),Components({resolvers: [ElementPlusResolver(),IconsResolver({enabledCollections: ['ep'],}),],}),Icons({autoInstall: true,}),createSvgIconsPlugin({// Specify the icon folder to be cachediconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],// Specify symbolId formatsymbolId: 'icon-[dir]-[name]',}),]}
})

然后svg图标的使用,例如全屏图标:

<el-button icon="FullScreen" circle @click="fullScreen" />

顺道写下全屏功能的实现:

<script lang="ts" setup>
import {reactive,ref} from 'vue';
//全屏功能
const fullScreen = ()=>{//用来判断是不是全屏,返回布尔值const full = document.fullscreenElement//有兼容问题if(full){document.exitFullscreen();}else{document.documentElement.requestFullscreen();}
}
</script>

在这里插入图片描述

components中的组件全局批量注册——避免使用时多次引入

在这里插入图片描述

步骤一:在components文件夹中新建index.ts文件

步骤二:在index.ts文件中引入各个组件

import SvgIcon from './SvgIcon/index.vue'
import Category from '@/components/Category/index.vue'

步骤三:使用vue中的AppComponent

import type { App, Component } from 'vue'
const allGlobalComponent: Component = { SvgIcon, Category }

步骤四:使用install方法来处理

export default {install(app: App) {Object.keys(allGlobalComponent).forEach((key: string) => {// 注册为全局组件app.component(key, allGlobalComponent[key])})},
}

结合文章中第一步的全局引入elementPlus图标,也可以放在此文件中:
完整代码如下:

import SvgIcon from './SvgIcon/index.vue'
import Category from '@/components/Category/index.vue'
import type { App, Component } from 'vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const allGlobalComponent: Component = { SvgIcon, Category }
export default {install(app: App) {Object.keys(allGlobalComponent).forEach((key: string) => {// 注册为全局组件app.component(key, allGlobalComponent[key])})// 将 element-plus 的图标注册为全局组件for (const [key, component] of Object.entries(ElementPlusIconsVue)) {app.component(key, component)}},
}

main.ts中引入components

import globalComponent from './components/index'
const app = createApp(App)
app.use(globalComponent)
http://www.mnyf.cn/news/171.html

相关文章:

  • 网站提交百度收录长沙官网seo技术厂家
  • 泰州腾讯网站开发如何做好网络营销?
  • 高端网站制作公司aso优化师
  • 做养生网站需要证件吗网页生成app
  • wordpress花生壳lamp广州网站营销seo
  • 3维网站制作技术销售平台
  • 公司做网站哪个公司做得好引擎优化是什么工作
  • 免费h5页面制作软件seo搜索引擎优化是什么
  • 培训app的制作网站的优化策略方案
  • 深圳建网站网站建设公司是怎么找客户
  • 徐州网站建设多少钱win10优化软件哪个好
  • 电子商务网站建设的一般流程2024年8月爆发新的大流行病毒吗
  • 手机logo在线制作 免费谷歌优化怎么做
  • 苏州做网站要多少钱网站设计公司北京
  • win7怎么做网站服务器seo日常工作都做什么的
  • 做网站注册35类哪几个小项百度关键词怎么设置
  • 网站被收录 但搜索不到主页aso排名优化知识
  • 阿里云里做网站能上百度首页么长春网站建设设计
  • 免费建网站郑州seo排名扣费
  • 传统企业网站建设运营分析杭州百度快照推广
  • wordpress更新以后进不去企业seo关键词优化
  • vs做网站如何发布网络舆情管控
  • 如何搭建网站建设环境武汉做网络推广的公司
  • 比较好的做网站的公司网络公司取什么名字好
  • 怎么做网站切图网站营销策略
  • 网站建设的基本流程是什么网络推广一般都干啥
  • 网站建设工作室最新的疫情防控政策和管理措施
  • 软文推广文章案例网站推广优化设计方案
  • b2c网站建设方案制作网页完整步骤代码
  • 北京丰台住房和城乡建设委员会网站制作网站的软件