2018-09-03 15:14:10 1557次浏览 2条回答 0 悬赏 10 金钱
<script src="/js/g_topmenu.js"></script>
<script>    var TP = {
	id:window.location.pathname,
	'URL' : 'http://y3.com',}
}; 
</script>

想要标签在上,链接在下,因为要引入标签里面的内容,


<script>    var TP = {
	id:window.location.pathname,
	'URL' : 'http://y3.com',}
}; 
</script>
<script src="/js/g_topmenu.js"></script>
  • 回答于 2018-09-03 15:47 举报

    registerJs() 和 registerJsFile() 内都有放置位置的选项,若 js file 以 asset 形式存在,通过调整 depends 依赖关系的顺序来改变加载的顺序。

  • 回答于 2018-09-03 17:42 举报

    在view里用

    $this->registerJs("var TP = {
    	id:window.location.pathname,
    	'URL' : 'http://y3.com',}
    }; ",View::POS_HEAD);
    
    $this->registerJsFile('/js/g_topmenu.js',['postion'=>View::POS_END]);
    

    这样就会js在上面,js文件在下面了~

您需要登录后才可以回答。登录 | 立即注册
蛋蛋的蛋
主管

蛋蛋的蛋

注册时间:2018-04-02
最后登录:2024-03-11
在线时长:34小时29分
  • 粉丝4
  • 金钱64
  • 威望20
  • 积分604

热门问题