Home >Backend Development >PHP Tutorial >Detailed tutorial on importing resource files into ThinkPHP template engine
ThinkPHP's template engine provides special tags to simplify the above import. 1.import tag The first one is the import tag. The import method adopts a namespace method similar to ThinkPHP's import function, for example: The default Type attribute is js, so the following effect is the same: can also support batch import of multiple files, for example: When importing external CSS files, the value of the type attribute must be specified, for example: The default import starting path in the above method is the Public directory under the root directory of the website , if you need to specify other directories, you can use the basepath attribute, for example: If the imported file contains a "." symbol, you can use : means importing the /Public/Js/Util/Array.min.js resource file. It also supports importing version numbers of resource files, for example: It can also be supported when importing multiple files improt tag supports judgment loading, For example, the following first determines whether the name variable is set: Or for more complex ones, you can even use functions: Compiled template cache yes:
2.load tag The second is the load tag, which imports the public JS or CSS of the current project through the URL, for example:
You can use special template tags to replace the href attribute, for example: Load tag does not need to specify the type attribute, the system will automatically determine based on the suffix. Of course, the load tag also supports conditional judgment calls: The system also provides two tag aliases js and css. The usage is consistent with load, for example: The load tag also supports importing multiple resource files at the same time, even different types of resource files: |