简体   繁体   English

如何将文件导入我的前端 main.js 文件?

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

I'm using wordpress, javascript and html我正在使用 wordpress、javascript 和 html

I am using wp_enqueue_script我正在使用wp_enqueue_script

Main.js includes, one hundred lines of code, so i want to break the code up into separate files. Main.js 包含一百行代码,所以我想将代码分解为单独的文件。

eg file 1, file 2, file 3.例如文件 1、文件 2、文件 3。

How can i import those files into the main.js file?如何将这些文件导入 main.js 文件?

I have tried using import, export statements but i get the error我曾尝试使用导入、导出语句,但出现错误

Cannot use import statement outside a module

try replacing import with require尝试用 require 替换 import

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的RequireJS main.js分为两个文件? - How to separate my RequireJS main.js into two files? Javascript 将 main.js 拆分为两个文件(导入?需要?) - Javascript split main.js into two files (import? require?) 如何在Vue中将Axios导入main.js? - How do I import Axios into main.js in Vue? 如何使用meteor 在服务器端main.js 上将数据插入到我的集合中? - How can I insert data to my collection on my server-side main.js with meteor? 如何防止外部脚本覆盖我的main.js配置 - How can I prevent an external script from overriding my main.js configuration Webpack Babel 脚本添加到我的索引中。html 文件需要是 src="/main.js" 但是 src="main.js"。 如何正确配置它? - Webpack Babel script added to my index.html file needs to be src="/main.js" but is src="main.js". How can I configure this correctly? 如何使用节点运行前端 Javascript 文件? - How can I run front end Javascript files with node? 我如何优化main.js的大小? - how can i optimize main.js size? 在Webpack中,如何通过单个条目main.js(文件中包含多个CSS文件)获得多个输出? - In Webpack, how to get multiple outputs with a single entry main.js(having multiple css files inside files)? 我该如何破坏缓存,以便用户获得所有新的静态文件(例如style.CSS,main.js)? - How do I bust the cache so users get all the new static files (eg. style.CSS, main.js)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM