This article provides a detailed analysis of the import file labels in thinkphp. For more information, see
This article provides a detailed analysis of the import file labels in thinkphp. For more information, see
The first is the 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 type attribute value, which is rented by a Hong Kong server. 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, U.S. space, variable 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. The Hong Kong virtual host, for example: