简体   繁体   中英

How can I import files into my front end main.js files?

I'm using wordpress, javascript and html

I am using wp_enqueue_script

Main.js includes, one hundred lines of code, so i want to break the code up into separate files.

eg file 1, file 2, file 3.

How can i import those files into the main.js file?

I have tried using import, export statements but i get the error

Cannot use import statement outside a module

try replacing import with require

// import { parse } from 'node-html-parser';
const parse = require('node-html-parser');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM