Parse the import file label in thinkphp

  • 2020-06-15 07:55:11
  • OfStack

The first is the import tag. The import mode adopts the namespace mode of import function similar to ThinkPHP, such as:

import tags (namespace introduced to resource files)

closed

Closing tags

attribute

file (must) : Resource file to be imported, supports variables

type (optional) : Introduced resource file type, js by default, supports js css and php

basepath (optional) : The base path to the namespace


Example:
< import type='js' file="Js.Util.Array" / >
The Type attribute defaults to js, so the following effect is the same:
< import file="Js.Util.Array" / >
Also can support multiple file batch import, such as:
< import file="Js.Util.Array,Js.Util.Date" / >
Import the external CSS file must specify the value of the type attribute, for example:
< import type='css' file="Css.common" / >
The default starting path of import is the site's Public directory. If you need to specify other directories, you can use the basepath attribute, such as:
< import file="Js.Util.Array" basepath="./Common" / >

The second is the load tag, which files into the common JS or CSS of the current project

load tag (use url to introduce resource file)

closed

Closing tags

attribute

href (must) : The resource file url address to be introduced, supports variables


Such as:
< load href="../Public/Js/Common.js" / >
< load href="../Public/Css/common.css" / >
The href property can be replaced with special template tags, such as:
< load href="__PUBLIC__/Js/Common.js" / >
The Load tag does not need to specify the type attribute, and the system automatically determines based on the suffix.
The system also provides two tag aliases js and css usage and load1 send, such as:
< js href="__PUBLIC__/Js/Common.js" / >
< css href="../Public/Css/common.css" / >


Related articles: