• uniapp-vue3-微信小程序-按钮组wo-btn-group


    采用uniapp-vue3实现, 是一款支持高度自定义的按钮组组件,支持H5、微信小程序(其他小程序未测试过,可自行尝试)

    可到插件市场下载尝试: https://ext.dcloud.net.cn/plugin?id=15012

    • 使用示例

    请添加图片描述

    <template>
    	<view>
    		<view class="name">按钮组组件: wo-btn-group</view>
    		<view class="card">
    			<view class="header">默认样式(包括disabled禁用)</view>
    			<view class="content">
    				<woBtnGroup :default-value="state.value" @change="onChange"></woBtnGroup>
    			</view>
    		</view>
    		<view class="card">
    			<view class="header">按钮形状:椭圆(默认)、方形、圆形</view>
    			<view class="content">
    				<view class="box">
    					<view class="title">默认椭圆:</view>
    					<woBtnGroup :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<view class="title">方形:</view>
    					<woBtnGroup :shape="'space'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<view class="title">圆形(圆形无边框):</view>
    					<woBtnGroup :shape="'round'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    			</view>
    		</view>
    		<view class="card">
    			<view class="header">轮廓:</view>
    			<view class="content">
    				<view class="box">
    					<woBtnGroup outline :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<woBtnGroup outline :shape="'space'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<woBtnGroup outline :shape="'round'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    			</view>
    		</view>
    		<view class="card">
    			<view class="header">自定义颜色:</view>
    			<view class="content">
    				<view class="box">
    					<woBtnGroup outline :color="'orange'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<woBtnGroup :color="'orange'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    			</view>
    		</view>
    		<view class="card">
    			<view class="header">自定义边框:</view>
    			<view class="content">
    				<view class="box">
    					<view class="title">无边框:</view>
    					<woBtnGroup :border-obj="state.borderStyle1" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<view class="title">虚线边框:</view>
    					<woBtnGroup outline :border-obj="state.borderStyle2" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<view class="title">圆角幅度:</view>
    					<woBtnGroup outline :border-obj="state.borderStyle3" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box">
    					<view class="title">边框宽度:</view>
    					<woBtnGroup :border-obj="state.borderStyle4" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    			</view>
    		</view>
    		<view class="card">
    			<view class="header">自定义暗黑模式:</view>
    			<view class="content">
    				<view class="box dark1">
    					<woBtnGroup :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box dark1">
    					<woBtnGroup :shape="'round'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box dark dark-border">
    					<woBtnGroup :shape="'round'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box dark dark-border">
    					<woBtnGroup :border-obj="state.borderStyle1" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box dark dark-border1">
    					<woBtnGroup :shape="'space'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    				<view class="box dark dark-border1">
    					<woBtnGroup :border-obj="state.borderStyle1" :shape="'space'" :default-value="state.value" :options="state.options" @change="onChange"></woBtnGroup>
    				</view>
    			</view>
    		</view>
    	</view>
    </template>
    
    <script setup lang="ts">
    import woBtnGroup from './woBtnGroup.vue'
    import { reactive } from 'vue';
    
    const state = reactive({
    	borderStyle1: {
    		isShow: false,
    		size: '4rpx',
    		style: 'dashed',
    		radius: '70rpx'
    	},
    	borderStyle2: {
    		isShow: true,
    		size: '4rpx',
    		style: 'dashed',
    		radius: '70rpx'
    	},
    	borderStyle4: {
    		isShow: true,
    		size: '12rpx',
    		style: 'solid',
    		radius: '70rpx'
    	},
    	borderStyle3: {
    		isShow: true,
    		size: '4rpx',
    		style: 'solid',
    		radius: '16rpx'
    	},
    	value: 1,
      options: [
        {
          label: '按钮1',
          value: 1,
        },
    		{
    		  label: '按钮2',
    		  value: 2,
    			disabled: true
    		},
        {
          label: '按钮3',
          value: 3,
        },
    		{
    		  label: '按钮4',
    		  value: 4,
    		},
    		{
    		  label: '按钮5',
    		  value: 5,
    		},
      ],
    });
    const onChange = (e: any) => {
    	console.log('点击按钮:', e);
    };
    </script>
    
    <style scoped>
    .flex-center {
    	display: flex;
    	justify-content: center;
    	align-items: center;
    }
    .name {
    	font-weight: bold;
    	padding: 40rpx 0 10rpx 20rpx;
    }
    .title {
    	padding-bottom: 10rpx;
    }
    .box {
    	margin: 20rpx
    }
    .dark1 {
    	background-color: black;
    	color: #fff;
    	border-radius: 70rpx;
    }
    .dark {
    	background-color: black;
    	color: #fff;
    }
    .dark-border {
    	padding: 10rpx;
    	border-radius: 70rpx;
    	border: 6rpx solid #3370FF;
    }
    .dark-border1 {
    	padding: 10rpx;
    	border: 6rpx solid #3370FF;
    }
    .card {
    	background: #f1f1f1;
    	margin: 40rpx 10rpx;
    	padding: 30rpx;
    	border-radius: 12rpx;
    }
    .header {
    	font-size: 26rpx;
    	display: flex;
    	align-items: center;
    	margin-bottom: 30rpx;
    }
    .content {
    	font-size: 24rpx;
    	/* padding-bottom: 20rpx; */
    	/* background-color: black; */
    	/* color: #fff; */
    }
    /* .btn-border {
    	font-size: 28rpx;
    	border: 4rpx solid #3370FF;
    	padding: 4rpx;
    	border-radius: 70rpx;
    } */
    </style>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
  • 相关阅读:
    代码随想录打卡第五十三天|309.最佳买卖股票时机含冷冻期 ● 714.买卖股票的最佳时机含手续费
    vuejs中封装axios请求集中管理
    腾讯再次证实XR部门成立,腾讯“良心发现”,为游戏业“添火”?
    DataFunSummit:2023年智能风控技术峰会-核心PPT资料下载
    【华为云】用VNC远程连接Ubuntu20.04图形界面
    【C++学习笔记】1.2 C++输入与输出
    2024年水利工程与交通运输国际学术会议(ICWCET 2024)
    鬼影、雨雪天气点云噪声处理
    CentOS 7下载安装MySQL 5.7以及连接虚拟机CentOS 7数据库教程
    SQL中的锁
  • 原文地址:https://blog.csdn.net/qq_42278240/article/details/133886034