How to optimize this code?

let importFn = (icon) = > {

import icon from "@/assets/monitor-data/" + icon + ".png";

}

import icon1 from "@ / assets/monitor-data/icon1.png";
import icon2 from "@ / assets/monitor-data/icon2.png";
import icon3 from "@ / assets/monitor-data/icon3.png";
import icon4 from "@ / assets/monitor-data/icon4.png";
vue project, originally intended to write a function, but the import line also reported an error. I don"t know why, how do we solve this repeated introduction-sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Apr.26,2021

  const context = require.context('@/assets/monitor-data', false, /\.png$/)
  const keys = context.keys()
  keys.forEach(path => {
    const img = context(path)
    console.log(img)
  })
The

method introduces all the png files in the'@ / assets/monitor-data' directory. If you need Filter, you can call the filter () method on the variable keys . You can also create a separate directory of files you need to import, so you don't need Filter.
if you report an error, do not use the alias of webpack. The alias has not been tested to see if it can be used.


it is also required to write in require,

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c3a0-346a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c3a0-346a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?