Similar to this introduction of multiple modules, how to simplify it into one sentence, such as import {A,B,C,D} from {'a.js' ,'b.js'....}
Created index.js under ../img/new
index.js
under
import img1 from './banner.png' ... module.exports = { img1, ... }
You can quote it like this
import { img1, img2 ... } from '../img/new';
Never used this method before.
If all the files on your right are js, it’s easy to solve, just write them all in one file improt {a, b, c} from xx.js, but the picture is...
improt {a, b, c} from xx.js
Take your file A that introduces multiple modules, package it separately into a module B, and then import and use module B.
If you are using webpack you can write like this
const context = require.context('../img/new/', true, /\.(html)$/); context.keys().forEach((filename) => { console.log(filename, context(filename)); });
Created
index.js
under
../img/newYou can quote it like this
Never used this method before.
If all the files on your right are js, it’s easy to solve, just write them all in one file
improt {a, b, c} from xx.js
, but the picture is...Take your file A that introduces multiple modules, package it separately into a module B, and then import and use module B.
If you are using webpack you can write like this