Created
December 17, 2020 03:54
-
-
Save dyxang/cb157b7a9c4379004e60db51e930be2a to your computer and use it in GitHub Desktop.
waline 懒加载
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="talkmoe"></div> | |
<script type="text/javascript"> | |
loadComments(); | |
function loadComments() { | |
if (typeof Waline === 'undefined') { | |
var getScript = (options) => { | |
var script = document.createElement('script'); | |
script.defer = true; | |
script.crossOrigin = 'anonymous'; | |
Object.keys(options).forEach((key) => { | |
script[key] = options[key]; | |
}); | |
document.body.appendChild(script); | |
}; | |
getScript({ | |
src: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js', | |
onload: () => { | |
newWaline(); | |
} | |
}); | |
} else { | |
newWaline(); | |
} | |
} | |
function newWaline() { | |
new Waline({ | |
el: '#talkmoe', | |
serverURL: '<%= commentSetting.walineSetting.serverurl %>', | |
placeholder:'Hello!留下你的足迹吧 !(可直接在评论框内粘贴图片)' | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment