更新
我正在考虑使用以下解决方案,这是一个好方法吗?
我正在开发一个从 wordpress 移植到 angularJS 的项目(稍后将在其自己的后端拥有)。必须保留一些已经存在的必需 javascript 文件。
我正在使用Angular ui 路由器来保持与以前相同的路由,以及库所需的状态。
这是我的问题,我在主“index.html”中加载了以下文件:
<script type='text/javascript' src='/wp-content/themes/twentyfourteen-child/assets/js/bootstrap.min0c54.js?ver=150923'></script>
<script type='text/javascript' src='/wp-content/themes/twentyfourteen-child/assets/js/svg-injector-min5b31.js?ver=4.3.1'></script>
<script type='text/javascript' src='/wp-content/themes/twentyfourteen-child/assets/js/bootstrap-select.min0c54.js?ver=150923'></script>
<script type='text/javascript' src='/wp-content/themes/twentyfourteen-child/assets/js/jquery.matchHeight.min0c54.js?ver=150923'></script>
<script type='text/javascript' src='/wp-content/themes/twentyfourteen-child/assets/js/imgw-mina8b3.js?ver=150526'></script>
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/jquery-cycle2.min0c54.js?ver=150923'></script>
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/scrollTo.min0c54.js?ver=150923'></script>
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/imgw_home_scripts-min0c54.js?ver=150923'></script>
这些文件是必需的。现在,当我路由到特定的 url 时,例如:
/a-new-url
指向模板:
/partial/a-new-url.html
因此,例如,此模板有一个使用这些 javascript 文件之一的轮播,但是轮播不再起作用,除非我将脚本标签复制并粘贴到部分. 现在这是一个糟糕的解决方案,并且会导致冗余,因为我必须对每个不同的部分都这样做。
处理和解决此问题的正确方法是什么?
轮播代码(根据要求)
在 index.html 中,body 标记中有以下文件:
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/jquery-cycle2.min0c54.js?ver=150923'></script>
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/scrollTo.min0c54.js?ver=150923'></script>
<script type='text/javascript-lazy' src='/wp-content/themes/twentyfourteen-child/assets/js/imgw_home_scripts-min0c54.js?ver=150923'></script>
我的调查表明,这个 html 是根据“id=home-slideshow”自动加载的
<div id="home-slideshow">
<div id="slides" class="home-slider">
<div class="slide" style="background-image: url(/wp-content/uploads/2014/05/home.jpg);">
</div>
<div class="slide" style="background-image: url(/wp-content/uploads/2014/05/1170780.jpg);">
</div>
<div class="slide" style="background-image: url(/wp-content/uploads/2014/05/ep.jpg);">
</div>
</div>
</div>