我要用webpack打包原生js,然后寫了個小demo測試一下:我寫了個test.js文件module.exports = { alertMsg:function(){ alert(1); }}然后在入口文件entry.js里面導(dǎo)入這個文件'use strict';let a = require('./home/test.js');module.exports = {a};下面index.html文件<!DOCTYPE html><html><head> <meta charset="utf-8"/> <script src="./common/jquery.min.js"></script> <script src="./bundle.js"></script></head><body> <div id="head"></div> <div> <button id="btn" onclick="alertMsg()">click</button> </div></body><script> window.alertMsg = a.alertMsg;</script></html>提示a未定義,我不知道是哪里理解出錯,是對es6的module?!迫切希望得到幫助。。。感謝
webpack打包原生js
qq_笑_17
2019-02-21 13:19:48