我有下面的代码来分享在线信使
<div class="line-it-button" data-lang="en" data-type="share-b" data-url="{{ current_path }}" style="display: none;"></div>
<script src="https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js" async="async" defer="defer"></script>如何使用attach_library包含JS?
{{ attach_library('https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js') }}如何附加async=“异步”defer=“延迟”?
试用
{{ attach_library('https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js', { 'async' : 'async', 'defer' : 'defer'}) }}但不起作用:
发布于 2018-01-19 09:41:34
在theme.libraries.yml文件中添加以下行
theme.social:
js:
'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js' : { external: true, defer: true, async: true }在你的树枝档案里
{{ attach_library('theme.social') }}清除缓存&它工作:)
https://drupal.stackexchange.com/questions/254087
复制相似问题