简体   繁体   中英

Symfony 4 how to specify base path that does not change with the current URL?

in symfony I have a script that changes my icon to another by updating the icon image file source located at asset/image.png but this only works on the homepage mysite.com .

If I go to another page with mysite.com/foo the file is 404 showing wrong path like this foo/asset/image.png

Why is it appending foo to the image source path ? How can I fix it please ?

I need a way to specify a base path that does not change with the current url

function foo(){
  $("#foo").fadeToggle(fadeSpeed, function () {
      $("#foo").attr("src", "/asset/image.png")
  })
}

The problem was I had no asset management system installed.

Everything was solved after installing asset composer require symfony/asset .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM