I wrote a lot of js code in the
template file, and now I want to transfer them to external resource files
But the ajax path inside needs to be parsed by thinkphp5
For example:
$.ajax("{:url('home/index')}")
If I transfer it directly, the url will not be parsed.
How to solve this problem?
Also,
will external text be faster than js written directly on the html page?
I have two solutions.
One is global variables, which are declared directly in the header template and the footer loads external files.
The other is to encapsulate most operations in closures and then call them directly in the footer!