微信小程序
本文件已定稿,最后修改时间 20240823 12:47
一、wxml组件和wxss适配
.wxml —- div
- view — div
- text文字:可以长按选中
- image — img
- button
- form
- input
- label
.wxss —- .css
单位:rpx
布局:弹性盒布局
二、JS数据-列表-条件渲染-事件
数据
data: {
str:"这是小程序"
city: [
"北京",
"上海",
"四川"
]
}列表渲染
<view wx:for='{{city}}' wx:key='{{index}}'>
{{ item }}
{{ index }}
</view>条件渲染
<view wx:if='{city.length > 0}'>
<text wx:for='{{city}}'>
{{ item }}
</text>
</view>
<view wx:else>
暂无数据...
</view>事件
bind:不会阻止冒泡
catch:会阻止冒泡
<view bindtap='btn'></view>
修改data中的数据
btn(){
this.setData({
str:'我已经修改你了'
})
}
三、请求接口和封装url
onLoad: function(){ |
四、页面跳转-路径传值
<!-- list.html --> |
<!-- list.js --> |
<!-- index.html --> |
<!-- index.js --> |
五、template的使用
template目录结构
- pages
- templates
- swiper-template
- swiper-template.wxml
- swiper-template.wxss
- swiper-template.js
- tabs-template
- swiper-template
- templates
- pages
template的使用
<template name='swiper'></template>
页面引入
wxml:
<import src='' />
<template is='swiper' data='{{数据1, 数据2...}}'></template>wxss:
@import '/pages/templates/swiper-template/swiper-tempalte.wxss';
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Camila's blog!
评论
GitalkValine