Problem: When I import ICONS, I need to import x from “@/assets/ ICONS /xxx.svg” every time; If I have 100icon, I need to import 100 times. Can I import all ICONS in my directory once?

Solution: Add these lines of code to the script to achieve the introduction of all ICONS.

This can be done by introducing all files with any suffix in a directory into the current file (remember this code).

<script lang="ts"> const importAll = (requireContext: __WebpackModuleApi.RequireContext) => requireContext.keys().forEach(requireContext); ImportAll (require.context(".. /assets/icons", true, /\.svg$/)); } catch (error) { console.log(error); } </script>Copy the code