The traditional method of importing external JS and CSS resource files is directly used in the Template File: The traditional method of importing external JS and CSS resource files is directly used in the template file:
-
-
The template engine that copies the code ThinkPHP provides specialized labels to simplify the preceding import. [-More-] the first import tag is the import tag. the import method adopts the namespace method similar to the import function of ThinkPHP. for example:
-
The default Type attribute of the copied code is js, so the following effects are the same:
-
The copy code also supports batch import of multiple files, for example:
-
When copying code to import an external CSS file, you must specify the value of the type attribute, for example:
-
Copy the code above. the default import Start Path is the Public directory under the root directory of the website. to specify other directories, you can use the basepath attribute, for example:
-
Copy the code. if the imported file contains ".", you can use:
-
Copy the code to import the/Public/Js/Util/Array. min. js resource file.
You can also import the version number of a resource file, for example:
-
Copying code can also be supported when multiple files are imported.
-
You can copy the improt label to determine whether to load the code. for example, you can first determine whether the name variable is set:
-
Copy the code or use functions that are more complex:
-
The template cache after the compiled copy code is:
- Script
Copy the code load tag. The second one is the load tag. import the public JS or CSS of the current project through URL, for example:
-
-
-
The copy code can be replaced by a special template tag in the href attribute, for example:
-
You do not need to specify the type attribute when copying the Load tag of the code. The system automatically determines the type based on the suffix.
Of course, the load tag also supports conditional judgment calls:
-
The replication code system also provides two label aliases. js and css are used in the same way as load. for example:
-
-
The copy code load tag also supports importing multiple resource files at the same time, or even different types of resource files:
-
Copy code