当前位置:网站首页>Customized template in wechat applet
Customized template in wechat applet
2022-07-28 13:36:00 【richest_ qi】
List of articles
Applet project
1. Define templates .
Create a new folder under the project root directory :templates, Used to store templates .
Folder templates I'm gonna go ahead and create a new folder :temp,temp Next new file :temp.wxml and temp.wxss.
temp.wxml in , adopt <template name=""></template> Define templates .
2. New page .
Create a new folder under the applet root directory :test, In the folder test Under the new Page:test.
3. Use template in target page .
Of the target page wxml File by <import src=""/> Import template wxml file .
Of the target page wxml File by <template is=""></template> Use templates .
Of the target page wxss Document approval @import "" Import template wxss file .
The main files involved in the code are :
- templates/temp/temp.wxml
- templates/temp/temp.wxss
- pages/test/test.json
- pages/test/test.wxml
- pages/test/test.wxss
- pages/test/test.js

templates/temp/temp.wxml
<!-- Define templates -->
<template name="my-template">
<view class="user-box">
<image class="avatar" src="{
{avatarUrl}}"/>
<view class="username">{
{username}}</view>
</view>
</template>
templates/temp/temp.wxss
.user-box{
text-align: center;
}
.user-box .avatar{
width: 300rpx;
height: 300rpx;
border-radius: 50%;
}
.user-box .username{
font-size: 48rpx;
font-family:fantasy;
color: #1761d8;
height: 80rpx;
line-height: 80rpx;
}
pages/test/test.json
{
"usingComponents": {
},
"navigationBarBackgroundColor": "#eee",
"navigationBarTextStyle": "black",
"navigationBarTitleText": " my "
}
pages/test/test.wxml
<import src="/templates/temp/temp.wxml"/>
<view class="test-container">
<template is="my-template" data="{
{...user}}"></template>
</view>
pages/test/test.wxss
@import "/templates/temp/temp.wxss";
.test-container{
height: 100%;
background: #eee;
}
pages/test/test.js
Page({
data:{
user:{
username:"Mr Duck",
avatarUrl:"/static/images/avatar.png"
}
}
})
Related links
Custom components in applets
WXML Syntax reference > Templates
WXML Syntax reference > quote
边栏推荐
- Gamestop bear market entered NFT trading, and established game retailers took advantage of Web3 to make a second spring
- 【黑马早报】字节估值缩水,降至2700亿美元;“二舅”视频作者回应抄袭;任泽平称取消商品房预售制是大势所趋;美联储宣布再加息75个基点...
- Cesium pit -- pit used by various API calls and API itself
- 从手机厂高位“出走”的三个男人
- Dry goods -- encapsulated anti shake and throttling method in the project
- 少儿编程 电子学会图形化编程等级考试Scratch二级真题解析(判断题)2022年6月
- Using auto.js to realize fifaol3 brush teaching assistant
- Mysql中DQL基本练习
- Realize the mutual value transfer between main window and sub window in WPF
- PCP parity principle arbitrage
猜你喜欢

微信小程序中自定义模板

.NET桌面开发的一些思考

火山石投资章苏阳:硬科技,下一个10年相对确定的答案

《TiDB 6.x in Action》发布,凝聚社区集体智慧的 6.x 实践汇总!

Smart touch screen LCD bathroom mirror light touch chip-dlt8t02s-jericho

Intrinsic value and time value of options

LeetCode·每日一题·1331.数组序号转换·离散化

少儿编程 电子学会图形化编程等级考试Scratch二级真题解析(判断题)2022年6月
![[FPGA] FIR filter - half band filter](/img/6e/d97b3842f80e37aa41b888384a14cb.png)
[FPGA] FIR filter - half band filter

Intra prediction and transform kernel selection based on Neural Network
随机推荐
朋友发来几个面试题
MySQL 实践篇 —— 主从复制
Half wave rectification light LED
LeetCode·每日一题·1331.数组序号转换·离散化
[FPGA]: MATLAB generates COE files
Bull spread portfolio
leetcode-190.颠倒二进制位
Volcanic stone investment Zhang Suyang: hard technology, the relatively certain answer in the next 10 years
倒计时 2 天!2022 中国算力大会:移动云邀您共见算力网络,创新发展
[matlab] IIR filter
管理区解耦架构见过吗?能帮客户搞定大难题的
I copied the bottom of the liquidated NFT, but was locked by opensea
Guide for using IP phone system and VoIP system
Jar package
How much do you know about JVM memory management
leetcdoe-342. 4的幂
为什么说Crypto游戏正在改变游戏产业?
二舅能治好年轻人的精神内耗吗?
基于深度学习的超分辨率重建
Getderivedstatefromprops lifecycle