doumeng3345 2014-02-08 12:30
浏览 75

如何在laravel布局中设置外部文件路径

I am using laravel

I have one layout file called admin in which i have some external files addes like

below this files are in public directory

  <script type="text/javascript" src="plugins/jquery.js"></script>
  <script type="text/javascript" src="plugins/plugins.js"></script> 
  <script type="text/javascript" src="plugins/main.js"></script>

Now i have two view one post and other is allpost

and route for each layout is like this

/posts for post view

/posts/1 for allposts view

Now when i load frst view everything workd fine it loads all the external dependancies

http://Myserver.com/plugins/jquery.js path for local file is correct

but when i load second view which is for particular post whith post id it can't load external files because it requires different path to load files like

http://Myserver.com/posts/plugins/jquery.js"

so how can i solve this problem so i can use same layout for both view.

thanks in advance, really appreciated.

  • 写回答

1条回答 默认 最新

  • doyz51819 2014-02-08 12:36
    关注

    Try add root slash in the beginning of js url:

    <script type="text/javascript" src="/plugins/jquery.js"></script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?