标签 - Java
2024
回溯经典案例
回溯经典案例
回溯基础
回溯基础
) saveToLocal.set('twikoo-newest-comments', JSON.stringify(twikooArray), 10/(60*24)) generateHtml(twikooArray) }).catch(function (err) { const $dom = document.querySelector('#card-newest-comments .aside-list') $dom.textContent= "无法获取评论,请确认相关配置是否正确" }) } if (typeof twikoo === 'object') { runTwikoo() } else { getScript('https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js').then(runTwikoo) } } const generateHtml = array => { let result = '' if (array.length) { for (let i = 0; i < array.length; i++) { result += '
' if (true) { const name = 'src' result += `${array[i].nick}` } result += `
${array[i].content}
${array[i].nick} /
` } } else { result += '没有评论' } let $dom = document.querySelector('#card-newest-comments .aside-list') $dom && ($dom.innerHTML= result) window.lazyLoadInstance && window.lazyLoadInstance.update() window.pjax && window.pjax.refresh($dom) } const newestCommentInit = () => { if (document.querySelector('#card-newest-comments .aside-list')) { const data = saveToLocal.get('twikoo-newest-comments') if (data) { generateHtml(JSON.parse(data)) } else { getComment() } } } newestCommentInit() document.addEventListener('pjax:complete', newestCommentInit) })