Skip to content

Instantly share code, notes, and snippets.



Created Nov 30, 2020
What would you like to do?
dynamic module import example
let currentIdx = 1
export function add() {
const $ul = document.getElementById("todo-list")
const $li = document.createElement("li")
$li.textContent = `할 일 ${currentIdx++}`
<!DOCTYPE html>
<html lang="ko">
<meta charset="UTF-8">
<button id="add-todo">할 일 추가</button>
<ul id="todo-list"></ul>
<script src="main.js" type="module"></script>
// import add from './add.js'
const onClick = e => {
import('./add.js').then(obj => {
document.getElementById("add-todo").addEventListener("click", onClick)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment