diff --git a/public/weigets.js b/public/weigets.js index c5ad285..bbb8a95 100644 --- a/public/weigets.js +++ b/public/weigets.js @@ -1,15 +1,16 @@ -export function createElement({ innerText, textContent, readOnly, children = [], dataset, style, classList = [], ...attributes }, tagName = 'div') { +export function createElement({ innerText, innerHTML, textContent, readOnly, children = [], dataset, style, classList = [], ...attributes }, tagName = 'div') { const element = document.createElement(tagName) for (const key in attributes) { if (key.startsWith('on')) element[key] = attributes[key] // 如果是事件则直接赋值 else element.setAttribute(key, attributes[key]) // 否则是属性则使用setAttribute } + if (dataset) Object.assign(element.dataset, dataset) if (style) Object.assign(element.style, style) if (classList.length) element.classList.add(...classList) if (textContent) element.textContent = textContent if (innerText) element.innerText = innerText + if (innerHTML) element.innerHTML = innerHTML if (readOnly) element.readOnly = readOnly - if (dataset) Object.assign(element.dataset, dataset) if (children) children.forEach(child => element.appendChild(child)) return element } @@ -95,14 +96,14 @@ export function UploadMusic(options) { console.log('dragover') event.preventDefault() event.stopPropagation() - if(dragStats) return + if (dragStats) return event.dataTransfer.dropEffect = 'copy' drop.style.display = 'block' }, ondragleave: event => { event.preventDefault() event.stopPropagation() - if(dragStats) return + if (dragStats) return clearTimeout(dragStats) dragStats = setTimeout(() => { drop.style.display = 'none'