Old small island learning program (2) custom components

(1) New Component
Under the new file name and directory components directory may be different
(2) reference component
Add a profile in the referenced assembly .json
{
"usingComponents": {
"like-cmp": "/components/like/index",
}
}

Path component: "/ components / like / index"
Path components by using the absolute path or will be error such as: Component is not found in path "pages / classic / components / like / index" (using by "pages / classic / classic")
Relative path will find siblings components used to go

A relative path using the path defined components:
"../../components/like/index"

"../../Components/like/index" in the applet equivalent to "/ components / like / index",
.. represents the return to parent directory



Alias ​​components: "like-cmp"
receiving an object usingComponents
{
"key":"value",
}
Key alias component assembly normative
Path component value

(3) components
Using components .wxml
<like-cmp/>

(4) Pictures
Pictures from the definition of the components can be placed from the directory of custom components do not need to put large images files in the directory folder

Guess you like

Origin www.cnblogs.com/guangzhou11/p/11260314.html