I'm having trouble understanding the workflow of webpack.
In a regular project, I would have something like this:
HTML:
<button onclick = "doSomething()"></button>
And then in javascript I'll write the function
function doSomething(){}
I understand as the project grows I need to make the javascript more modular using Webpack. But how do I make the bundled javascript interact with the HTML? For example:
entry.js (pseudo code):
import moduleThatDoesThings;
moduleThatDoesThings.js:
function doSomething(){}
This won't work:
HTML:
<button onclick="moduleThatDoesThings.doSomething()"></button>
How do I call functions from modules in the HTML? Or am I supposed to think like this at all? If not how should I structure the project?
React有它自己的render()函数,您可以在其中放置html代码并与组件方法进行交互
因此,我了解到可以在vanilla js上的每个元素上使用react或执行element.addEventListener。
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.