This article provides a detailed analysis of the import file labels in thinkphp. For more information, see the first import tag. the import method adopts the namespace method similar to the import function of ThinkPHP, for example:
Import tag (use namespace to introduce resource files) |
Close |
Close tags |
Attribute |
File (required): The Resource file to be introduced. variables are supported. Type (optional): type of the introduced resource file. the default value is js. js css and php are supported. Basepath (optional): Basic path of the namespace |
Example:
The default Type attribute is js, so the following effects are the same:
You can also import multiple files in batches, for example:
To import an external CSS file, you must specify the value of the type attribute. for example:
In the above method, the default import Start Path is the Public directory of the website. to specify other directories, you can use the basepath attribute, for example:
The second is the load tag, which imports the public JS or CSS of the current project through the file method.
LoadTag (use url to introduce resource files) |
Close |
Close tags |
Attribute |
Href (required): url address of the resource file to be introduced. variables are supported. |
For example:
You can replace the href attribute with a special template tag, for example:
You do not need to specify the type attribute for the Load tag. The system automatically determines the type based on the suffix.
The system also provides two label aliases. js and css are used in the same way as load. for example: