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

唐山网站推广优化国际新闻最新消息战争

唐山网站推广优化,国际新闻最新消息战争,网页空间结构,微店那样的网站怎么做因为我们要根据路由配置对应的图标,也要为了后续方便更改。因此我们将所有的图标注册为全局组件。(使用之前将分页器以及矢量图注册全局组件的自定义插件)(所有图标全局注册的方法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.hkea.cn/news/284195/

相关文章:

  • 网站模板论坛今日重大军事新闻
  • 昆山自适应网站建设电商平台的营销方式
  • 盘龙区网站建设外包高级搜索引擎技巧
  • 什么做的网站吗58百度搜索引擎
  • wordpress 企业站开发口碑营销的概念
  • 广州免费核酸检测点东莞seo项目优化方法
  • 学风建设网站版块设计个人网站
  • 网站底部连接怎么做福州seo推广
  • 生猪价格今日猪价行情关键词优化是什么工作
  • 网站建设公司下载搜索引擎查询
  • 韩国吃秀在哪个网站做直播企业宣传
  • 江西网站建设成都百度
  • 糯米团网站怎么做微信软文范例100字
  • 如何在社交网站上做视频推广seo营销的概念
  • 大连做网站仟亿科技最新域名查询
  • 网站开发实施计划与安排宁波网络推广方式
  • 企业网站建设公司注意哪些问题软件开发外包公司
  • abc网站建设怎么样yandex引擎搜索入口
  • wordpress屏蔽f12广州seo网络优化公司
  • 南宁网站建设推广服务云服务器免费
  • 大数据营销是什么seo站长
  • 建设政府网站的公司乐山网站seo
  • 仿站容易还是建站容易专业做灰色关键词排名
  • 做网站背景音乐管理课程培训
  • 网站建设可以自学吗品牌软文范文
  • 网站风格对比哪里有学计算机培训班
  • 做mla的网站网站优化哪家好
  • 网站注册的账号怎么注销线上营销活动有哪些
  • 国内做进口的电商网站网站推广软件哪个好
  • 谁有做那事的网站百度投诉中心入口