更新记录

2.0.0(2023-06-21)

组件优化

1.0(2023-06-10)

组件初始化


平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.8.0 app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

cc-radioView

使用方法


<!-- radioData:单选数据 curIndex:当前选择序列 @change:单选事件 -->
<cc-radioView :radioData="items" :curIndex="current" @change="radioChange"></cc-radioView>

HTML代码实现部分


<template>
    <view>

        <!-- radioData:单选数据 curIndex:当前选择序列 @change:单选事件 -->
        <cc-radioView :radioData="items" :curIndex="current" @change="radioChange"></cc-radioView>

        <button class="botBtn" type="primary" @click="submitBtnClick">完成</button>

        <!-- 设置按钮下面仍然可以滑动 -->
        <view style="height: 30px;"></view>
    </view>
</template>

<script>
    export default {

        data() {
            return {

                items: [{
                        value: '1',
                        name: '事项一'
                    },
                    {
                        value: '2',
                        name: '事项二',
                        checked: ''
                    },
                    {
                        value: '3',
                        name: '事项三'
                    },
                    {
                        value: '4',
                        name: '事项四'
                    },
                    {
                        value: '5',
                        name: '事项五'
                    },
                    {
                        value: '6',
                        name: '事项六'
                    },
                    {
                        value: '7',
                        name: '事项七'
                    },
                    {
                        value: '8',
                        name: '事项八'
                    },

                ],
                current: 0,

            };
        },
        onLoad(e) {

            let tmpObj = {};
            if (typeof(e.obj) === 'string') {

                tmpObj = JSON.parse(e.obj);
                // 查找元素位置
                this.current = this.items.findIndex((el) => {
                    return el.name === tmpObj.name
                });

            }

            console.log("序列 = " + this.current);
            console.log("正向传值 = " + JSON.stringify(tmpObj));
        },
        methods: {
            radioChange: function(evt) {
                for (let i = 0; i < this.items.length; i++) {
                    if (this.items[i].value === evt.target.value) {
                        this.current = i;
                        break;
                    }
                }

            },
            submitBtnClick: function(e) {
                console.log("选中的条目 = " + JSON.stringify(this.items[this.current]));

                this.$eventHub.$emit('fire', this.items[this.current]);

                uni.navigateBack({
                    delta: 1
                })

            }
        }
    };
</script>

<style>
    /*每个页面公共css */

    .botBtn {
        width: 90%;
        margin-left: 5%;
        margin-top: 80rpx;
        height: 92rpx;
        /* background-color: #F36526 !important; */

    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问