We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
语法:const req= require.context(directory, useSubdirectories = false, regExp = /^.//);
例子1:多文件便捷载入(例子2有展示)
例子2:多文件便捷载入之SVG图标解决方案(elementUI使用的该方法,除此之外还可以使用Unicode、font-class详见参考资料)
目录说明: svg文件夹存放svg图标并与index.js同目录存放 index.js: import Vue from 'vue' import SvgIcon from '@/components/SvgIcon'// svg component // register globally Vue.component('svg-icon', SvgIcon) const req = require.context('./svg', false, /\.svg$/) const requireAll = requireContext => requireContext.keys().map(requireContext) requireAll(req) SvgIcon组件: <template> <svg :class="svgClass" aria-hidden="true"> <use :href="iconName" /> </svg> </template> <script> export default { name: 'SvgIcon', props: { iconClass: { type: String, required: true }, className: { type: String, default: '' } }, computed: { iconName() { return `#icon-${this.iconClass}` }, svgClass() { if (this.className) { return 'svg-icon ' + this.className } else { return 'svg-icon' } } } } </script> <style scoped> .svg-icon { width: 1em; height: 1em; vertical-align: -0.15em; fill: currentColor; overflow: hidden; } </style>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
语法:const req= require.context(directory, useSubdirectories = false, regExp = /^.//);
例子1:多文件便捷载入(例子2有展示)
例子2:多文件便捷载入之SVG图标解决方案(elementUI使用的该方法,除此之外还可以使用Unicode、font-class详见参考资料)
The text was updated successfully, but these errors were encountered: