当前位置: 首页 > news >正文

【微信小程序】6天精准入门(第4天:自定义组件及案例界面)附源码

一、自定义组件

1、介绍

        从小程序基础库版本 1.6.3 开始,小程序支持简洁的组件化编程。所有自定义组件相关特性都需要基础库版本 1.6.3 或更高。

        开发者可以将页面内的功能模块抽象成自定义组件,以便在不同的页面中重复使用;也可以将复杂的页面拆分成多个低耦合的模块,有助于代码维护。自定义组件在使用时与基础组件非常相似

2、创建自定义组件

类似于页面,一个自定义组件由 json wxml wxss js 4个文件组成。要编写一个自定义组件,首先需要在 json 文件中进行自定义组件声明(将 component 字段设为 true 可将这一组文件设为自定义组件):

{"component": true
}

同时,还要在 wxml 文件中编写组件模板,在 wxss 文件中加入组件样式,它们的写法与页面的写法类似。具体细节和注意事项参见 组件模板和样式 。

在项目中创建一个components/tabs文件夹,新建Component文件

【注意】

在新的版本里面我们会出现报错,但是在win7的一些旧版本里面是不会出现这些问题的,我们需要在project.config.json文件里面添加以下代码:

"ignoreDevUnusedFiles": false,
"ignoreUploadUnusedFiles": false,

同时,还要在 wxml 文件中编写组件模板,在 wxss 文件中加入组件样式,它们的写法与页面的写法类似。具体细节和注意事项参见 组件模板和样式 。

代码示例:

<view class="inner">{{innerText}}
</view>
<slot></slot>
/* 这里的样式只应用于这个自定义组件 */
.inner {color: red;
}

注意:在组件wxss中不应使用ID选择器、属性选择器和标签名选择器。

在自定义组件的 js 文件中,需要使用 Component() 来注册组件,并提供组件的属性定义、内部数据和自定义方法。

组件的属性值和内部数据将被用于组件 wxml 的渲染,其中,属性值是可由组件外部传入的。更多细节参见 Component构造器 。

代码示例:

Component({properties: {// 这里定义了innerText属性,属性值可以在组件使用时指定innerText: {type: String,value: 'default value',}},data: {// 这里是一些组件内部数据someData: {}},methods: {// 这里是一个自定义方法customMethod: function(){}}
})

3、使用自定义组件

使用已注册的自定义组件前,首先要在页面的 json 文件中进行引用声明。此时需要提供每个自定义组件的标签名和对应的自定义组件文件路径:

{"usingComponents": {"tabs": "/components/tabs/tabs"}
}

这样,在页面的 wxml 中就可以像使用基础组件一样使用自定义组件。节点名即自定义组件的标签名,节点属性即传递给组件的属性值。

在wxml里面使用<tabs>自定义标签

<tabs inner-text='6666'></tabs>

4、案例---头部导航

使用自定义组件,实现头部导航的一个效果

首先我们要在组件里面定义好

tabs.wxml

<view class="tabs"><view class="tabs_title"><view wx:for="{{tabList}}" wx:key="id" class="title_item  {{index==tabIndex?'item_active':''}}" bindtap="handleItemTap" data-index="{{index}}"><view style="margin-bottom:5rpx">{{item}}</view><view style="width:30px" class="{{index==tabIndex?'item_active1':''}}"></view></view></view><view class="tabs_content"><slot></slot></view>
</view>

tabs.js

// components/tabs/tabs.js
Component({/*** 组件的属性列表*/properties: {//定义了组件所需要的属性值tabList:Object},/*** 组件的初始数据*/data: {},/*** 组件的方法列表*/methods: {}
})

wxss

/* components/tabs/tabs.wxss */
.inner {color: red;}.tabs {position: fixed;top: 0;width: 100%;background-color: #fff;z-index: 99;border-bottom: 1px solid #efefef;padding-bottom: 20rpx;
}.tabs_title {/* width: 400rpx; */width: 90%;display: flex;font-size: 9pt;padding: 0 20rpx;
}.title_item {color: #999;padding: 15rpx 0;display: flex;flex: 1;flex-flow: column nowrap;justify-content: center;align-items: center;
}.item_active {/* color:#ED8137; */color: #000000;font-size: 11pt;font-weight: 800;
}.item_active1 {/* color:#ED8137; */color: #000000;font-size: 11pt;font-weight: 800;border-bottom: 6rpx solid #333;border-radius: 2px;
}

我们在指定的页面调用自定义好的组件

json文件里面设置调用组件

{"usingComponents": {"tabs" : "/components/tabs/tabs"}
}

wxml文件里面添加自定义的组件

<tabs tabList="{{tabs}}" bindtabsItemChange="tabsItemChange">
</tabs>

在js文件里面设置值

// pages/meeting/list/list.js
Page({/*** 页面的初始数据*/data: {tabs: ['会议中', '已完成', '已取消', '全部会议']},/*** 生命周期函数--监听页面加载*/onLoad(options) {},/*** 生命周期函数--监听页面初次渲染完成*/onReady() {},/*** 生命周期函数--监听页面显示*/onShow() {},/*** 生命周期函数--监听页面隐藏*/onHide() {},/*** 生命周期函数--监听页面卸载*/onUnload() {},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh() {},/*** 页面上拉触底事件的处理函数*/onReachBottom() {},/*** 用户点击右上角分享*/onShareAppMessage() {}
})

二、案例界面设置

完成会议、投票、个人中心页面的设计

1、会议

在上面已经拥有的基础上进行一个点击数据的展示

在自定义组件的js文件里面进行方法的编写

    /*** 组件的方法列表*/methods: {handleItemTap(e){// 获取索引const {index} = e.currentTarget.dataset;// 触发 父组件的事件this.triggerEvent("tabsItemChange",{index})this.setData({tabIndex:index})}}

在会议的页面的wxml文件里面进行页面的编写

<tabs tabList="{{tabs}}" bindtabsItemChange="tabsItemChange">
</tabs>
<view style="height: 100rpx;"></view>
<block wx:for-items="{{lists}}" wx:for-item="item" wx:key="item.id"><view class="list" data-id="{{item.id}}"><view class="list-img al-center"><image class="video-img" mode="scaleToFill" src="{{item.image}}"></image></view><view class="list-detail"><view class="list-title"><text>{{item.title}}</text></view><view class="list-tag"><view class="state al-center">{{item.state}}</view><view class="join al-center"><text class="list-num">{{item.num}}</text>人报名</view></view><view class="list-info"><text>{{item.address}}</text>|<text>{{item.time}}</text></view></view></view>
</block>
<view class="section"><text>到底啦</text>
</view>

在js文件的里面模拟假的数据

/*** 页面的初始数据*/data: {tabs: ['会议中', '已完成', '已取消', '全部会议'],lists: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '进行中','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '进行中','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '进行中','time': '10月09日 17:31','address': '大连市'},{'id': '1','image': '/static/persons/4.jpg','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','num': '150','state': '进行中','time': '10月09日 17:21','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/5.jpg','title': '新质生活 · 品质时代 2016消费升级创新大会','num': '217','state': '进行中','time': '10月09日 16:59','address': '北京市·朝阳区'}],lists1: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '已结束','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已结束','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '已结束','time': '10月09日 17:31','address': '大连市'}],lists2: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '已取消','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已取消','time': '10月09日 17:39','address': '北京市·朝阳区'}],lists3: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '进行中','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已结束','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '进行中','time': '10月09日 17:31','address': '大连市'},{'id': '1','image': '/static/persons/4.jpg','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','num': '150','state': '已结束','time': '10月09日 17:21','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/5.jpg','title': '新质生活 · 品质时代 2016消费升级创新大会','num': '217','state': '进行中','time': '10月09日 16:59','address': '北京市·朝阳区'}]}

在下面编写一个方法,用来获取对应的数据

 tabsItemChange(e) {console.log(e)let tolists;if (e.detail.index == 0) {tolists = this.data.lists;} else if (e.detail.index == 1) {tolists = this.data.lists1;} else if (e.detail.index == 2) {tolists = this.data.lists2;} else {tolists = this.data.lists3;}this.setData({lists: tolists})}

完整代码

// pages/meeting/list/list.js
Page({/*** 页面的初始数据*/data: {tabs: ['会议中', '已完成', '已取消', '全部会议'],lists: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '进行中','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '进行中','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '进行中','time': '10月09日 17:31','address': '大连市'},{'id': '1','image': '/static/persons/4.jpg','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','num': '150','state': '进行中','time': '10月09日 17:21','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/5.jpg','title': '新质生活 · 品质时代 2016消费升级创新大会','num': '217','state': '进行中','time': '10月09日 16:59','address': '北京市·朝阳区'}],lists1: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '已结束','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已结束','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '已结束','time': '10月09日 17:31','address': '大连市'}],lists2: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '已取消','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已取消','time': '10月09日 17:39','address': '北京市·朝阳区'}],lists3: [{'id': '1','image': '/static/persons/1.jpg','title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】','num': '304','state': '进行中','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '1','image': '/static/persons/2.jpg','title': 'AI WORLD 2016世界人工智能大会','num': '380','state': '已结束','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/3.jpg','title': 'H100太空商业大会','num': '500','state': '进行中','time': '10月09日 17:31','address': '大连市'},{'id': '1','image': '/static/persons/4.jpg','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','num': '150','state': '已结束','time': '10月09日 17:21','address': '北京市·朝阳区'},{'id': '1','image': '/static/persons/5.jpg','title': '新质生活 · 品质时代 2016消费升级创新大会','num': '217','state': '进行中','time': '10月09日 16:59','address': '北京市·朝阳区'}]},tabsItemChange(e) {console.log(e)let tolists;if (e.detail.index == 0) {tolists = this.data.lists;} else if (e.detail.index == 1) {tolists = this.data.lists1;} else if (e.detail.index == 2) {tolists = this.data.lists2;} else {tolists = this.data.lists3;}this.setData({lists: tolists})},/*** 生命周期函数--监听页面加载*/onLoad(options) {},/*** 生命周期函数--监听页面初次渲染完成*/onReady() {},/*** 生命周期函数--监听页面显示*/onShow() {},/*** 生命周期函数--监听页面隐藏*/onHide() {},/*** 生命周期函数--监听页面卸载*/onUnload() {},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh() {},/*** 页面上拉触底事件的处理函数*/onReachBottom() {},/*** 用户点击右上角分享*/onShareAppMessage() {}
})

2、投票

绑定自定义组件

json

{"usingComponents": {"tabs" : "/components/tabs/tabs"}
}

wxml

<!--pages/vote/list/list.wxml-->
<!-- <text>投票</text> -->
<!-- <tabs inner-text='6666'></tabs> -->
<view><tabs tabList="{{tabs}}" bindtabsItemChange="tabsItemChange"></tabs><view style="height: 120rpx;    background-color: #aaa;"></view><block wx:for-items="{{lists}}" wx:for-item="item" wx:key="item.id"><view class="list" data-id="{{item.id}}"><view class="list-img al-center"><image class="video-img" mode="scaleToFill" src="{{item.image}}"></image></view><view class="list-detail"><view class="list-title"><text><text style="margin-right: 13rpx;"> 发 起 人</text> : {{item.name}}</text></view><view class="list-title"><text>会议名称 : {{item.title}}</text></view><view class="list-title"><text>投票标题 : [ {{item.vote}} ]</text></view><view class="list-tag"><view class="state al-center">{{item.state}}</view><view class="join al-center"><text class="list-count">{{item.count}}</text>人参与投票</view></view><view class="list-info"><text style="font-weight: bold;">地址:</text><text>{{item.address}}</text> <text style="float: right;">{{item.time}}</text> </view><view> <button class="btn">参与</button></view></view></view></block><view class="section bottom-line"><text>到底啦</text></view>
</view>

js

// pages/vote/list/list.js
Page({/*** 页面的初始数据*/data: {tabs: ['全部', '已投票', '未投票'],lists: [{'id': '1','image': '/static/persons/3.jpg','name': '张三','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','vote': '是否认同与京东进行产品合作','count': '304','state': '未投票','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '2','image': '/static/persons/6.jpg','name': '刘兵','title': 'AIWORLD人工智能大会','vote': '是否投资AI发展','count': '480','state': '已投票','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '3','image': '/static/persons/3.jpg','name': '李四','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','vote': '是否太空商业进行合作','count': '500','state': '未投票','time': '10月09日 17:31','address': '大连市'},{'id': '4','image': '/static/persons/7.jpg','name': ' 王五 ','title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”','vote': '是否对本次创新持续升级','count': '217','state': '已投票','time': '11月20日 16:59','address': '北京市·朝阳区'}],lists1: [{'id': '1','image': '/static/persons/4.jpg','name': '赵六','title': '新质生活 · 品质时代 2016消费升级创新大会','vote': '是否认同与京东进行产品合作','count': '304','state': '已投票','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '2','image': '/static/persons/2.jpg','name': '管理员','title': '新质生活 · 品质时代 2016消费升级创新大会','vote': '是否投资AI发展','count': '480','state': '已投票','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '3','image': '/static/persons/3.jpg','name': '张三','title': 'H100太空商业大会','vote': '是否太空商业进行合作','count': '500','state': '已投票','time': '10月09日 17:31','address': '大连市'},{'id': '4','image': '/static/persons/5.jpg','name': ' 李四 ','title': 'CSDN消费升级创新大会','vote': '是否对本次创新持续升级','count': '217','state': '已投票','time': '11月20日 16:59','address': '北京市·朝阳区'}],lists2: [{'id': '1','image': '/static/persons/4.jpg','name': '张三','title': '深圳·北京PM大会','vote': '是否认同与京东进行产品合作','count': '422','state': '未投票','time': '10月09日 17:59','address': '深圳市·南山区'},{'id': '2','image': '/static/persons/6.jpg','name': '李四','title': 'AIWORLD人工智能大会','vote': '是否投资AI发展','count': '377','state': '未投票','time': '10月09日 17:39','address': '北京市·朝阳区'},{'id': '3','image': '/static/persons/3.jpg','name': '王五','title': 'H100太空商业大会','vote': '是否太空商业进行合作','count': '463','state': '未投票','time': '10月09日 17:31','address': '大连市'},{'id': '4','image': '/static/persons/5.jpg','name': ' K&赵六 ','title': '2023消费升级创新大会','vote': '是否对本次创新持续升级','count': '543','state': '未投票','time': '11月20日 16:59','address': '北京市·朝阳区'}]},tabsItemChange(e) {console.log(e.detail);let tolists;if (e.detail.index == 0) {tolists = this.data.lists;} else if (e.detail.index == 1) {tolists = this.data.lists1;} else if (e.detail.index == 2) {tolists = this.data.lists2;} else {tolists = this.data.lists;}this.setData({lists: tolists})},/*** 生命周期函数--监听页面加载*/onLoad(options) {},/*** 生命周期函数--监听页面初次渲染完成*/onReady() {},/*** 生命周期函数--监听页面显示*/onShow() {},/*** 生命周期函数--监听页面隐藏*/onHide() {},/*** 生命周期函数--监听页面卸载*/onUnload() {},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh() {},/*** 页面上拉触底事件的处理函数*/onReachBottom() {},/*** 用户点击右上角分享*/onShareAppMessage() {}
})

wxss样式

/* pages/vote/list/list.wxss */
.list {display: flex;flex-direction: row;width: 100%;padding: 0 20rpx 0 0;background-color: seashell;border-bottom: 1px solid #cecece;margin-bottom: 5rpx;height: 350rpx;
}.list-img {display: flex;margin: 10rpx 10rpx;width: 160rpx;height: 250rpx;justify-content: center;align-items: center;flex-direction: column;
}.list-img .video-img {width: 140rpx;height: 160rpx;border-radius: 6px;
}.list-detail {margin: 10rpx 10rpx;display: flex;flex-direction: column;width: 600rpx;height: 300rpx;
}.list-title text {font-size: 9pt;color: #333;font-weight: bold;
}.list-detail {display: flex;height: 100rpx;
}.list-tag {display: flex;
}.state {font-size: 9pt;color: blue;width: 120rpx;height: 40rpx;border: 1px solid blue;border-radius: 2px;margin: 10rpx 0rpx;display: flex;justify-content: center;align-items: center;
}.join {font-size: 11pt;color: #bbb;margin-left: 20rpx;display: flex;justify-content: center;align-items: center;
}.list-count {margin-right: 10rpx;font-size: 11pt;color: red;
}.list-info {font-size: 9pt;color: #bbb;
}.btn {/* width: 10rpx;height: 40rpx;background-color: #3388ff;color: #fff;text-align: center;font-size: 16rpx;display: flex;justify-content: center;align-items: center; */background-color: #3388ff;color: #fff;border-radius: 4rpx;font-size: 16rpx;padding: 10rpx 20rpx;/* background-color: #3388ff;color: #fff;border-color: #3388ff; *//* width: 100rpx;height: 40rpx;border: 1rpx solid #3388ff;border-radius: 4rpx;font-size: 16rpx;background-color: #3388ff;color: #fff;outline: none;box-shadow: 0 0 5rpx #3388ff; *//* width: 60rpx;height: 30rpx;border-radius: 4rpx;font-size: 16rpx; *//* width: 40rpx;height: 40rpx;background-color: transparent;border: none;font-size: 24rpx;color: #666; */}.bottom-line {display: flex;height: 60rpx;justify-content: center;align-items: center;background-color: #f3f3f3;
}.bottom-line text {font-size: 9pt;color: #666;
}

3、个人中心

wxml

<!--pages/ucenter/index/index.wxml-->
<!-- <text>个人中心</text> -->
<view class="user"><image class="user-img"  src="/static/persons/1.jpg"></image><view class="user-name">无法自律的人</view><text class="user-state">状态:😊</text><text class="user-up">修改></text>
</view>
<view class="cells"><view class="cell-items"><image src="/static/tabBar/coding-active.png" class="cell-items-icon"></image><text class="cell-items-title">我主持的会议</text><text class="cell-items-num">99+</text><text class="cell-items-detail">🆗</text></view><view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);"></view><view class="cell-items"><image src="/static/tabBar/sdk.png" class="cell-items-icon"></image><text class="cell-items-title">我参与的会议</text><text class="cell-items-num">99+</text><text class="cell-items-detail">❤</text></view>
</view>
<view style="height: 27rpx;background-color: rgba(135, 206, 250, 0.075);"></view>
<view class="cells"><view class="cell-items"><image src="/static/tabBar/sdk.png" class="cell-items-icon"></image><text class="cell-items-title">我发布的投票</text><text class="cell-items-num">89</text><text class="cell-items-detail">👍</text></view><view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);"></view><view class="cell-items"><image src="/static/tabBar/coding-active.png" class="cell-items-icon"></image><text class="cell-items-title">我参与的投票</text><text class="cell-items-num">8</text><text class="cell-items-detail">></text></view>
</view>
<view style="height: 27rpx;background-color: rgba(135, 206, 250, 0.075);"></view>
<view class="cells"><view class="cell-items"><image src="/static/tabBar/template.png" class="cell-items-icon"></image><text class="cell-items-title">信息</text><text class="cell-items-ion">></text></view><view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);"></view><view class="cell-items"><image src="/static/tabBar/component.png" class="cell-items-icon"></image><text class="cell-items-title">设置</text><text class="cell-items-ion">></text></view>
</view>

wxss

/* pages/ucenter/index/index.wxss */
Page {background-color: rgba(135, 206, 250, 0.075);
}.user {display: flex;width: 100%;align-items: center;background-color: white;margin-bottom: 28rpx;
}.user-img {height: 170rpx;width: 170rpx;margin: 30rpx;border: 1px solid #cdd7ee;border-radius: 6px;
}.user-name {width: 380rpx;margin-left: 20rpx;font-weight: 550;
}.user-state {color: rgb(136, 133, 133);
}.user-up {color: rgb(136, 133, 133);
}.cells {background-color: white;
}.cell-items {display: flex;align-items: center;height: 110rpx;
}.cell-items-title {width: 290rpx;
}.cell-items-icon {width: 50rpx;height: 50rpx;margin: 20rpx;
}.cell-items-num {padding-left: 30rpx;margin-left: 200rpx;width: 70rpx;
}.cell-items-ion {margin-left: 295rpx;
}

相关文章:

【微信小程序】6天精准入门(第4天:自定义组件及案例界面)附源码

一、自定义组件 1、介绍 从小程序基础库版本 1.6.3 开始&#xff0c;小程序支持简洁的组件化编程。所有自定义组件相关特性都需要基础库版本 1.6.3 或更高。 开发者可以将页面内的功能模块抽象成自定义组件&#xff0c;以便在不同的页面中重复使用&#xff1b;也可以将复杂的页…...

pragma once与ifndef的区别

概要 代码编译过程中&#xff0c;为了防止同一份代码被重复引用&#xff0c;通常有两种实现方式 方式一 #pragma once 方式二 #ifndef _TEST_H_ #define _TEST_H_ #endif // !TEST_H 通常情况下&#xff0c;使用上述两种方式中的任意一种都是可以的。最近工作中&#xff0c;代…...

52单片机独立键盘控制数码管计数

前言 使用52单片机实现独立键盘控制数码管计数 代码 #include<reg52.h> #define uchar unsigned char #define uint unsigned intsbit key2 P3^4; sbit key3 P3^5; sbit key4 P3^6; sbit key5 P3^7;char code smg[] {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x…...

完美解决 在将最终稿件上传到 IEEE PDF eXpress进行格式检查是出现“font not embedded“的问题 (不会出现自动压缩图像的现象)

最近中了一篇IEEE的论文&#xff0c;在校稿阶段&#xff0c;final paper是需要通过IEEE PDF eXpress网站的格式检查&#xff0c;然后出现一下问题&#xff1a; Errors: Font TimesNewRomanPS-BoldMT, TimesNewRomanPS-ItalicMT, TimesNewRomanPSMT is not embedded 用人话说就…...

零基础学习CSS

01-CSS初体验 层叠样式表 (Cascading Style Sheets&#xff0c;缩写为 CSS&#xff09;&#xff0c;是一种 样式表 语言&#xff0c;用来描述 HTML 文档的呈现&#xff08;美化内容&#xff09;。 书写位置&#xff1a;title 标签下方添加 style 双标签&#xff0c;style 标签…...

基于Flume+Kafka+Hbase+Flink+FineBI的实时综合案例(五)FineBI可视化

文章目录 22&#xff1a;FineBI配置数据集23&#xff1a;FineBI构建报表24&#xff1a;FineBI实时配置测试附录二&#xff1a;离线消费者完整代码 22&#xff1a;FineBI配置数据集 目标&#xff1a;实现FineBI访问MySQL结果数据集的配置 实施 安装FineBI 参考《FineBI Windows…...

Python逆向爬虫案例: 某网站AES逆向解密

前言 嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 环境使用: Python 3.8 Pycharm &#x1f447; &#x1f447; &#x1f447; 更多精彩机密、教程&#xff0c;尽在下方&#xff0c;赶紧点击了解吧~ python源码、视频教程、插件安装教程、资料我都准备好了&#xff0…...

ONNX runtime本地终端部署

1、class_index.csv文件&#xff1a; ID,English,Chinese 0,A,你 1,B,我 2,C,他 3,D,她2、classification.onnx 3、单张图像处理代码如下&#xff1a; import onnxruntime import torch import torch.nn.functional as F import pandas as pd from PIL import Image from tor…...

Linux性能优化--性能工具:特定进程CPU

4.0 概述 在用系统级性能工具找出是哪个进程降低了系统速度之后&#xff0c;你需要用特定进程性能工具来发现这个进程的行为。对此&#xff0c;Linux提供了丰富的工具用于追踪一个进程和应用程序性能的重要统计信息。 阅读本章后&#xff0c;你将能够&#xff1a; 确定应用程…...

技术人员转岗产品经理,有优势吗?

产品经理是一个非技术型的岗位&#xff0c;但是懂一些技术相关的知识会更好的和技术部门沟通&#xff0c;能更好的从技术部门的角度理解需求的可行性。所以这么说来&#xff0c;技术转产品经理相对来说更加有优势。 任何事情不可能都是只有好处没有坏处的&#xff0c;同样的&a…...

使用IDEA2022.1创建Maven工程出现卡死问题

使用IDEA创建Maven工程出现卡死问题&#xff0c;这个是一个bug 这里是别人和官方提供这个bug,大家可以参考一下 话不多说&#xff0c;上教程 解决方案&#xff1a; 方案1&#xff1a;更新idea版本 方案2&#xff1a;关闭工程&#xff0c;再新建&#xff0c;看图...

Nuttx Syscall

在Nuttx系统中&#xff0c;mksyscall工具用于根据syscall/syscall.csv文件生成供用户调用的接口和内核中对应的接口。具体来说&#xff0c;mksyscall -p system.csv生成供用户调用的接口&#xff0c;而mksyscall -s system.csv生成内核中调用的接口。 在syscall/syscall.csv文…...

HTTP协议中GET请求和POST请求的区别

1. 形式上&#xff1a; GET请求&#xff1a;参数包含在URL中&#xff0c;意味着参数的长度是有限的&#xff0c;并且参数只能是ASCII码的形式。 POST请求&#xff1a;参数包含在请求体中&#xff0c;参数的长度是不受限&#xff0c;并且参数支持多种数据类型。 2.安全性 GET请…...

【广州华锐互动】利用VR开展施工现场安全培训,提高员工安全意识水平

随着科技的不断发展&#xff0c;虚拟现实&#xff08;VR&#xff09;技术已经逐渐渗透到各个领域&#xff0c;为我们带来了前所未有的沉浸式体验。在建筑施工行业&#xff0c;VR技术的应用也日益广泛&#xff0c;从设计、施工到管理&#xff0c;都可以看到VR技术的身影。而在这…...

Cornerstone for Mac:高效SVN管理的黄金标准

在当今的软件开发领域&#xff0c;版本控制系统是不可或缺的一部分。其中&#xff0c;Subversion&#xff08;SVN&#xff09;是一个广泛使用的版本控制系统&#xff0c;有助于团队协同工作&#xff0c;实现代码的版本管理和追踪。对于Mac用户来说&#xff0c;Cornerstone是一款…...

数据结构之顺序表的模拟实现

&#x1f495;"世事犹如书籍&#xff0c;一页页被翻过去。人要向前看&#xff0c;少翻历史旧账。"&#x1f495; 作者&#xff1a;Mylvzi 文章主要内容&#xff1a;数据结构之顺序表的模拟实现 /*** Created with IntelliJ IDEA.* Description:* User: 绿字* Date:…...

R6G azide, 5-isomer具有良好的水溶性,2135330-71-9

试剂 | 基础知识概述&#xff08;部分&#xff09;: 英文名称&#xff1a;R6G azide, 5-isomer CAS&#xff1a;2135330-71-9 分子式&#xff1a;C30H32N6O4 分子量&#xff1a;540.61 规格标准&#xff1a;10mg&#xff0c;25mg&#xff0c;50mg&#xff0c;可提供mg级以…...

Canvas系列绘制图片学习:绘制图片和渐变效果

我们现在已经可以绘制好多东西了&#xff0c;不过在实际开发中&#xff0c;绘制最多的当然是图片了&#xff0c;这章我们就讲讲图片的绘制。 绘制图片 绘制图片的API是drawImage&#xff0c;它的参数有三种情况&#xff1a; // 将图片绘制在canvas的(dX, dY)坐标处 context.…...

AJAX为什么叫AJAX

AJAX&#xff08;Asynchronous JavaScript and XML&#xff09;这个名字是由美国程序员Jesse James Garrett在2005年提出的&#xff0c;用来描述一种用于创建交互式Web应用程序的技术组合。它之所以被称为"AJAX"&#xff0c;有以下原因&#xff1a; Asynchronous&…...

自动化测试中如何编写配置文件 ? 该使用什么工具 ? 一文详解使用ConfigParser读写配置文件

1. 配置文件说明 只要是用编写项目&#xff0c;你就肯定离不开配置文件 。就以测试人员编写的自动化测试项目为例 &#xff0c;如果你做连接数据库 、访问一些第三方接口、或者访问登录接口的用户名和密码。这些输入的信息最大特点就是都可能是变量&#xff0c;比如访问数据库…...

文件批量管理:轻松复制备份并删除原文件

在日常生活和工作中&#xff0c;我们经常需要处理大量的文件。为了确保文件的安全性和完整性&#xff0c;您需要一种高效的文件批量管理方法。本文将向您介绍如何一一复制备份并删除原文件里的文件&#xff0c;让您的文件管理变得轻松便捷。 首先&#xff0c;我们要进入文件批…...

Linux高性能服务器编程 学习笔记 第十七章 系统监测工具

tcpdump是一款经典的抓包工具&#xff0c;即使今天我们已经有了像Wireshark这样更易于使用和掌握的抓包工具&#xff0c;tcpdump仍是网络程序员的必备利器。 tcpdump提供了一些选项用以过滤数据包或定制输出格式&#xff0c;常见的选项如下&#xff1a; 1.-n&#xff1a;使用I…...

rabbitmq 消费者报错 ListenerExecutionFailedException NullPointerException

报错信息&#xff1a; org.springframework.amqp.rabbit.support.ListenerExecutionFailedException: Listener method private void com.xxx.service.impl.xxxServiceImpl.xxx(com.xxx.dto.XXX) threw exception at org.springframework.amqp.rabbit.listener.adapter.Mes…...

Java面试题:链表-合并两个排序的链表

描述 输入两个递增的链表&#xff0c;单个链表的长度为n&#xff0c;合并这两个链表并使新链表中的节点仍然是递增排序的。 示例 输入&#xff1a; {1,3,5}, {2,4,6}返回值&#xff1a; {1,2,3,4,5,6}原题地址&#xff1a;https://www.nowcoder.com/practice/d8b6b4358f7742…...

Springboot结合Mockito写单元测试实践和原理

文章目录 前言一、使用最佳实践使用场景SpyBean失效场景解决Mock失效的问题避免FactoryBean的实现方式使用MockBean&#xff0c;但是要指定name 个人推荐 二、原理1. MockBean2.SpyBean方法调用 总结 前言 相信看我博客的都是javaer&#xff0c;工作中一般都是使用Springboot框…...

操作系统之微内核架构

宏内核相反&#xff0c;微内核架构提倡功能尽可能少&#xff0c;只提供进程调度、处理中断、内存映射、进程间通信等功能。微内核架构是不能够提供什么实际功能的&#xff0c;而内存管理、进程管理、设备管理和文件管理服务等&#xff0c;都被做成一个个服务进程&#xff0c;它…...

24---WPF缓存

一、什么是缓存&#xff1a; 1.缓存指的是将需要频繁访问的网络内容存放在离用户较近、访问速度更快的系统中&#xff0c;以提高内容访问速度的一种技术。缓存服务器就是存放频繁访问内容的服务器。 2.缓存就是一个临时存放区域--离用户比较近 二、作用--意义---如果系统出现故…...

vite+vue3.0 使用tailwindcss

参考资料&#xff1a; 安装 - TailwindCSS中文文档 | TailwindCSS中文网 npm install -D tailwindcss npm install postcss npm install autoprefixer npx tailwindcss init -p 生成/src/tailwind.config.js和/src/postcss.config.js配置文件 在/src/tailwind.config.js配置文件…...

C++QT---QT-day3

使用手动连接&#xff0c;将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中&#xff0c;在自定义的槽函数中调用关闭函数将登录按钮使用qt5版本的连接到自定义的槽函数中&#xff0c;在槽函数中判断ui界面上输入的账号是否为"admin"&#xff0c;密码是否为&…...

小程序如何搭建在服务器上

小程序可以通过搭建在服务器上&#xff0c;来实现跨平台的访问和使用。以下是搭建小程序在服务器上的步骤&#xff1a; 安装Node.js&#xff1a;首先&#xff0c;你需要在服务器上安装Node.js。你可以从Node.js的官方网站下载并安装。 安装微信开发者工具&#xff1a;然后&…...