1
我一定会错过Webpack或JS真正基本的东西。我只是想在窗体的提交函数中调用一个捆绑函数。我收到一个找不到函数的消息,我找不到原因。onsubmit函数无法找到webpack绑定的函数
错误 的index.html:13未捕获的ReferenceError:双没有定义
index.html的(闭为了简洁移除标签)
<head>
<script type="text/javascript" src="bundle.js"></script>
<body>
<form name='myform' onsubmit="doStuff(event); return false;">
<button type="submit">Press Me!</button>
<script type="text/javascript">
function doStuff(e) {
e.preventDefault();
console.log(double(32));
}
abc.js(的WebPack入口点)
var a = require('./double');
double.js
function double(number) {
return number * 2;
}
module.exports.double = double;
包...
$ webpack abc.js bundle.js
Hash: 0e65404017702c54dac5
Version: webpack 1.13.2
Time: 59ms
Asset Size Chunks Chunk Names
bundle.js 1.58 kB 0 [emitted] main
[0] ./abc.js 28 bytes {0} [built]
[1] ./double.js 80 bytes {0} [built]
任何帮助表示赞赏