当前位置:网站首页>小程序创建组件
小程序创建组件
2022-07-28 05:25:00 【像费曼%】
1.创建组件

1.2局部引用组件
//页面.json文件
{
"usingComponents": {
"test1":"/components/test/test1"
}
}
//页面.wxml文件
<text>pages/list/list.wxml</text>
<view></view>//强制换行一下
<test1></test1>
1.3全局应用(在app.json文件中配置)
1.4全局引用vs局部应用
根据组件的使用频率和范围,选择合适的方式
- 如果某组件在多个页面经常被使用到,建议进行“全局引用”
- 若只在某特定的页面使用过,建议进行“局部应用”
1.5组件和页面的区别
从表面看,组件和页面都是由.js .json .wxml .wxss这四个文件组成。但是,组件和页面.js与.json文件有明显区别:
- 组件的.json文件中需要声明“component:true”属性
- 组件的.js文件中调用的是Component()函数
- 组件的事件处理函数需要定义到methods节点中
边栏推荐
猜你喜欢

Word邮件合并功能详解:合并后生成多个word文档,删除空白页

qt中Qthread线程的使用以及安全关闭

Monitor the CPU temperature of raspberry pie 4B installed with esxi on ARM

VAN(DWConv+DWDilationConv+PWConv)

set_multicycle_path

qt实现将相关信息输出到日志文件

Cronbach’s α? Kmo coefficient? Factor load? The most understandable course of questionnaire reliability and validity analysis in history!!! (SPSS and AMOS)

测量电脑电池容量

clickhouse建宽表多少列最合适?

The startup fails when switching Chinese when using wampserver3.2.6
随机推荐
论文神器 VS Code + LaTex + LaTex Workshop
天线效应解决办法
ICC2(三)Clock Tree Synthesis
mysql join技巧
Paper artifact vs code + latex + latex workshop
Analysis of MOSFET damage at the moment of power failure of isolated power supply
Talk about the "hybrid mode" of esxi virtual switch and port group
EfficientNET_ V1
qt中获取当前目录
Talking about fluke optical cable certification? What is CFP? What is OFP?
我的注解笔记
Fluke dtx-1800 and its accessories dtx-cha002 channel adapter channel replacement RJ45 socket notes
qt解析字符串转为json数据并解析
USB network native driver for esxi updated to support esxi7.0.1
Cronbach’s α?KMO系数?因子载荷?史上最易懂的问卷信效度分析教程!!!(SPSS和AMOS)
Esxi on ARM v1.2 (updated in November 2020)
【学习笔记】编码能力
【学习笔记】驱动
ICC2使用report_placement检查floorplan
USB network native driver for esxi updated to support esxi7.0 Update 2