当前位置:网站首页>小程序介绍
小程序介绍
2022-06-12 09:16:00 【小威要向诸佬学习呀】
文章目录
小程序代码的构成 - WXML 模板
1. 什么是 WXML
2. WXML 和 HTML 的区别
小程序代码的构成 - WXSS 样式
1. 什么是 WXSS
2. WXSS 和 CSS 的区别
小程序代码的构成 - JS 逻辑交互
1. 小程序中的 .js 文件
2. 小程序中 .js 文件的分类
小程序代码的构成 - WXML 模板
- 什么是 WXML
WXML(WeiXin Markup Language)是小程序框架设计的一套 标签语言 , 用来构建小程序页面的结构 ,其作用类似于网页开发中的 HTML。 - WXML 和 HTML 的区别
① 标签名称不同
HTML (div, span, img, a)
WXML(view, text, image, navigator)
② 属性节点不同
超链接
③ 提供了类似于 Vue 中的模板语法
数据绑定
列表渲染
条件渲染
aaa
aaa
div标签在小程序中不能换行了
小程序代码的构成 - WXSS 样式
- 什么是 WXSS
WXSS (WeiXin Style Sheets)是一套 样式语言 ,用于描述 WXML 的组件样式,类似于网页开发中的 CSS。 - WXSS 和 CSS 的区别
① 新增了 rpx 尺寸单位
CSS 中需要手动进行像素单位换算,例如 rem
WXSS 在底层支持新的尺寸单位 rpx,在不同大小的屏幕上小程序会自动进行换算
② 提供了全局的样式和局部样式
项目根目录中的 app.wxss 会作用于所有小程序页面
局部页面的 .wxss 样式仅对当前页面生效
③ WXSS 仅支持部分 CSS 选择器
.class 和 #id
element
并集选择器、后代选择器
::after 和 ::before 等伪类选择器
当然你可以把HTML和CSS放入小程序中:
效果:
HTML(放入WXML中):
<!--pages/tsj/tsj.wxml-->
<button class="c-button c-button--gooey"> Hover me
<div class="c-button__blobs">
<div></div>
<div></div>
<div></div>
</div>
</button>
<svg style="display: block; height: 0; width: 0;" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="goo">
<feGaussianBlur result="blur" stdDeviation="10" in="SourceGraphic"></feGaussianBlur>
<feColorMatrix result="goo" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" mode="matrix" in="blur"></feColorMatrix>
<feBlend in2="goo" in="SourceGraphic"></feBlend>
</filter>
</defs>
</svg>
CSS(放入WXSS中):
/* pages/tsj/tsj.wxss */
/* From www.lingdaima.com */
.c-button {
color: #000;
font-weight: 700;
font-size: 16px;
text-decoration: none;
padding: 0.9em 1.6em;
cursor: pointer;
display: inline-block;
vertical-align: middle;
position: relative;
z-index: 1;
}
.c-button--gooey {
color: #06c8d9;
text-transform: uppercase;
letter-spacing: 2px;
border: 4px solid #06c8d9;
border-radius: 0;
position: relative;
transition: all 700ms ease;
}
.c-button--gooey .c-button__blobs {
height: 100%;
filter: url(#goo);
overflow: hidden;
position: absolute;
top: 0;
left: 0;
bottom: -3px;
right: -1px;
z-index: -1;
}
.c-button--gooey .c-button__blobs div {
background-color: #06c8d9;
width: 34%;
height: 100%;
border-radius: 100%;
position: absolute;
transform: scale(1.4) translateY(125%) translateZ(0);
transition: all 700ms ease;
}
.c-button--gooey .c-button__blobs div:nth-child(1) {
left: -5%;
}
.c-button--gooey .c-button__blobs div:nth-child(2) {
left: 30%;
transition-delay: 60ms;
}
.c-button--gooey .c-button__blobs div:nth-child(3) {
left: 66%;
transition-delay: 25ms;
}
.c-button--gooey:hover {
color: #fff;
}
.c-button--gooey:hover .c-button__blobs div {
transform: scale(1.4) translateY(0) translateZ(0);
}
小程序代码的构成 - JS 逻辑交互
- 小程序中的 .js 文件
一个项目仅仅提供界面展示是不够的,在小程序中,我们通过 .js 文件来处理用户的操作。例如:响应用户的点击、获取用户的位置等等。 - 小程序中 .js 文件的分类
小程序中的 JS 文件分为三大类,分别是:
① app.js
是 整个小程序项目的入口文件 ,通过调用 App() 函数 来启动整个小程序
② 页面的 .js 文件
是 页面的入口文件 ,通过调用 Page() 函数 来创建并运行页面
③ 普通的 .js 文件
是 普通的功能模块文件 ,用来封装 公共的函数或属性 供页面使用
边栏推荐
- Hotspot Metaspace
- Visualization of two-dimensional feature logistic regression prediction results
- Technology cloud report: how will the industrial Internet rebuild the security boundary in 2022?
- Bash tutorial
- Financial test interview questions to help you get the offer
- JVM garbage collection
- Common omissions in software test reports, give yourself a wake-up call
- 测试用例如何编写?
- node示例后台搭建
- NiO principle
猜你喜欢
![Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays](/img/6b/6dcc86bfe0f48103ef8420b9996c1e.jpg)
Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays

Implementation of hotspot reference

Definition of polar angle and its code implementation

List < string > sort

ThreadLocal

卖疯了的临期产品:超低价、大混战与新希望

EIP-1559

Can you migrate backwards before the first migration in the south- Can you migrate backwards to before the first migration in South?

Filters and listeners
软件测试需求分析方法有哪些,一起来看看吧
随机推荐
解决當打開Unity時 提示項目已經打開,而自己之前並沒有打開過(可能之前异常關閉)的問題
Latex common symbols summary
Microservice gateway
Grab screen and ground glass effect
128. longest continuous sequence hash table
(15) Tweenrunner
Chapter 3 registers (memory access)
数据库常见面试题都给你准备好了
Distributed transaction solution 1: TCC (compensation transaction)
Sword finger offer:[day 8 dynamic planning (simple)] --- > frog jumping on steps
清华大学数据挖掘笔记(一)
Common omissions in software test reports, give yourself a wake-up call
Description of string
EIP-1559
Several ways to restart kubernetes pod
Jenkins Pipeline 语法
Jenkins pipeline syntax
目标识别、检测和 6D 姿态估算源码与方案(最先进的方法和数据集)
L1-019 who goes first
[computer use] how to change a computer disk into a mobile disk?