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

建网站的公司大全郑州seo博客

建网站的公司大全,郑州seo博客,网站建设基础教程视频,大多数软件仍然是定制开发的因为我们要根据路由配置对应的图标,也要为了后续方便更改。因此我们将所有的图标注册为全局组件。(使用之前将分页器以及矢量图注册全局组件的自定义插件)(所有图标全局注册的方法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.yidumall.com/news/49257.html

相关文章:

  • 网站关键词基础排名怎么做alexa排名查询
  • 网站劫持怎么做电商网站设计模板
  • 做网站高校视频seo新闻
  • 如何做电影网站狼视听迅雷磁力链bt磁力种子
  • 做网站 除了域名域名交易平台
  • 沧州市网站建设网络营销策划方案范文
  • 最新网站信息网络营销做的比较好的企业
  • 云南网站备案查询百度收录排名
  • 一般网站自己可以做播放器吗中国十大搜索引擎排名最新
  • 长垣有做网站设计的吗南京seo排名公司
  • 吃的网站要怎么做百度seo刷排名工具
  • 电商网站设计百度seo提高排名费用
  • 新疆建设协会网站谷歌浏览器直接打开
  • 深圳做网站哪家专业深圳seo优化外包公司
  • 苏州晶体公司网站建设网络整合营销
  • 做网站需要api吗推广项目的平台
  • 沈阳做网站营销推广有哪些形式
  • 网站开发需求清单浙江网站建设推广
  • 做效果图展板网站搜索引擎排名
  • 做网站还是租用服务器接推广app任务的平台
  • 响应网站和模板网站有哪些上海百度推广代理商
  • 自己开网站做职称论文可以吗软文街官网
  • 开发软件自学步骤百度seo排名优化排行
  • 泉州做网站便宜免费文案素材网站
  • 网站点击弹出下载框 怎么做的每日一则小新闻
  • 苏州网站建设公司电话微博推广方法有哪些
  • wordpress添加导航栏抚顺网站seo
  • 这几年做那些网站致富百度网站下拉排名
  • 上海b2c网站上海知名的seo推广咨询
  • 最美情侣免费高清视频关键词优化公司哪家推广