简体   繁体   English

什么是处理Assetic(symfony2)调用的javascript文件中URL的最佳方法

[英]What is the best way to handle URLs in javascript files called by assetic (symfony2)

I am using assetic in a twig template to include a javascript file from my bundle's public folder. 我在树枝模板中使用Assetic来包含我包的公共文件夹中的javascript文件。 The problem is this JS file has URLs in it to call other pages using jQuery. 问题是此JS文件中包含URL,以使用jQuery调用其他页面。

How should i handle these URLs? 我应该如何处理这些URL? I could write the URLs as absolute paths - but this causes problems between the dev and prod environment, and also makes the application not very portable. 我可以将URL编写为绝对路径-但这会导致开发环境和生产环境之间出现问题,并使应用程序不太容易移植。 What is the best way to do such things? 做这种事情的最好方法是什么?

Maybe moving those urls to a configuration file . 也许将这些URL移到配置文件中。

that config.js can be generated via twig and contain the proper urls generated from the routing table config.js可以通过树枝生成,并包含从路由表生成的正确网址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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