Home  >  Article  >  Backend Development  >  php写web项目解决方案

php写web项目解决方案

WBOY
WBOYOriginal
2016-06-13 12:52:111180browse

php写web项目
写web项目,页面中的js是单独拿出来放在一个js文件中比较好,还是直接写在html页面中比较好?有什么优缺点?

php?js? web html php js
------解决方案--------------------
无论如何,需求总是第一位的!
既然你已经在js中使用了就对路径,并且也不愿意改成相对路径
那么讨论内置还是外联不是已经没有必要了吗?
当然你也可以将独立的js文件当做子模板嵌入进主模板中
------解决方案--------------------
你可以建一个专门存放路径的js文件,这个文件中定义好所有的路径变量;其他js文件使用这个文件定义好的路径变量。然后这个专门存放路径的js文件在其他js文件前引入即可。
如定义path.js
里面定义 var filePath="****";
然后其他文件中用这个filePath作为路径。
使用时,在页面中定义:
<script></script>
<script></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn