zoukankan      html  css  js  c++  java
  • 学习旧岛小程序 (2) 自定义组件

    (1) 新建组件
    新建组件目录下的文件名字可以与目录不一样
    (2)引用组件
    在引用的组件的 .json 添加配置
    {
    "usingComponents": {
    "like-cmp": "/components/like/index",
    }
    }

    "/components/like/index" : 组件的路径
    组件的路径要使用绝对路径不然会报错 比如:Component is not found in path "pages/classic/components/like/index" (using by "pages/classic/classic")
    相对路径会找到使用组件的同级组件中去

    使用相对路径定义组件的路径:
    "../../components/like/index"

    "../../components/like/index" 在小程序中相当与 "/components/like/index",
    .. 表示返回上级目录



    "like-cmp" :组件的别名
    usingComponents 接收一个对象
    {
    "key":"value",
    }
    key 组件的别名 制订组件的规范
    value 组件的路径

    (3)使用组件
    使用组件.wxml
    <like-cmp/>

    (4)图片
    自定义组件的图片可以放到自定义组件的目录下 不须放 到大目录下的images 文件夹
  • 相关阅读:
    linux 重启网卡的方法
    linux find命令详解
    linux grep命令
    linux ls命令详解
    linux ping命令详解
    FTP命令使用详解
    linux du命令详解
    linux scp命令详解
    linux curl用法详解
    Linux top命令的图解使用
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/11260314.html
Copyright © 2011-2022 走看看