import './style.css' import javascriptLogo from './javascript.svg' const form = `
` document.querySelector('#app').innerHTML = ` ` //插入style const style = document.createElement('style') style.innerHTML = ` .option-box { margin: 2rem 0; } ` document.head.appendChild(style) // 选中图像后将#bg的背景图片设置为选中的图像 const bg = document.querySelector('#bg') const file = document.querySelector('input[type=file]') file.addEventListener('change', (e) => { const file = e.target.files[0] const reader = new FileReader() reader.onload = (e) => { bg.style.backgroundImage = `url(${e.target.result})` } reader.readAsDataURL(file) })