Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement vue icon selector

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to achieve the vue icon selector", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to achieve vue icon selector" bar!

Import Vue from 'vue'import SvgIcon from' @ / components/SvgIcon'// svg component / / register globallyVue.component ('svg-icon', SvgIcon) const req = require.context ('. / svg', false, /\ .svg $/) const requireAll = requireContext = > requireContext.keys () .map (requireContext) requireAll (req)

# replace default config # multipass: true# full: true plugins: #-name # # or: #-name: false #-name: true# # or: #-name: # param1: 1 # param2: 2-removeAttrs: attrs:-'fill' -' fill-rule'

/ / doc: https://panjiachen.github.io/vue-element-admin-site/feature/component/svg-icon.html#usageimport {isExternal} from'@ / utils/validate' export default {name: 'SvgIcon', props: {iconClass: {type: String, required: true}, className: {type: String, default:''}} Computed: {isExternal () {return isExternal (this.iconClass)}, iconName () {return `# icon-$ {this.iconClass}`}, svgClass () {if (this.className) {return 'svg-icon' + this.className} else {return' svg-icon'}} StyleExternalIcon () {return {mask: `url (${this.iconClass}) no-repeat 50% 50% `,'- webkit-mask': `url (${this.iconClass}) no-repeat 50% 50%`}}. Svg-icon {width: 1em Height: 1mm; vertical-align:-0.15em; fill: currentColor; overflow: hidden;} .SVG-external-icon {background-color: currentColor; mask-size: covertly important; display: inline-block;}

{{item}} import icons from'. / requireIcons'export default {name: 'IconSelect', data () {return {name:', iconList: icons}}, methods: {filterIcons () {this.iconList = icons if (this.name) {this.iconList = this.iconList.filter (item = > item.includes (this.name))}} SelectedIcon (name) {this.$emit ('selected', name) document.body.click ()}, reset () {this.name =' 'this.iconList = icons}}. Icon-body {width: 100% Padding: 10px; .icon-list {height: 200px; overflow-y: scroll; div {height: 30px; line-height: 30px; margin-bottom:-5px; cursor: pointer; width: 33%; float: left;} span {display: inline-block; vertical-align:-0.15em; fill: currentColor Overflow: hidden;}

Thank you for your reading, the above is the content of "how to achieve vue icon selector", after the study of this article, I believe you have a deeper understanding of how to achieve vue icon selector, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report