资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何使用Link,Radio,Checkbox,Select,Cascader组件

这篇文章主要介绍“如何使用Link,Radio,Checkbox,Select,Cascader组件”,在日常操作中,相信很多人在如何使用Link,Radio,Checkbox,Select,Cascader组件问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何使用Link,Radio,Checkbox,Select,Cascader组件”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的大田网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

1.Link组件动态绑定URL


    
        
            
                默认链接
            
        
    

对应的js代码


    new Vue({
        el: '#home',
        data: {
            href: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {
                this.href = "https://www.baidu.com/"
            }
        }
    })

2.Radio 用法


    备选项1
    备选项2
    备选项3

对应的js代码


    new Vue({
        el: '#home',
        data: {
            addType: null       # 必须声明绑定的值,否则页面无法渲染
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            radioChange() {
                console.log(this.addType)
            }
        }
    })

当选项被选中时,会调用radioChange方法。

3.Checkbox用法

方式一:

对应的js代码


    new Vue({
        el: '#home',
        data: {
            num: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            checkChange() {
                console.log(this.num)
            }
        }
    })

当标签中的值改变时,会调用handleChange方法。

方式二:


搜索

对应的js代码


    new Vue({
        el: '#home',
        data: {
            num: '',
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            getSearch() {
                console.log(this.num)
            }
        }
    })

当搜索按钮被点击时,会触发getSearch方法,获取到num的值。

4.Select 用法

方式一:

el-option中只需要声明keyvalue的值即可


    

搜索

对应的js代码


    new Vue({
        el: '#home',
        data: {
            options: [],
            value: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {
                this.options = [
                    {
                        value: '黄金糕',
                        label: '黄金糕'
                    }, {
                        value: '双皮奶',
                        label: '双皮奶'
                    }, {
                        value: '蚵仔煎',
                        label: '蚵仔煎'
                    }, {
                        value: '龙须面',
                        label: '龙须面'
                    }, {
                        value: '北京烤鸭',
                        label: '北京烤鸭'
                    }
                ]
            },
            getSearch() {
                console.log(this.value)
            }
        }
    })

可以先声明options为空数组,然后在init方法中为options数组赋值(可以异步请求后端数据,将后端响应数据赋值)

当搜索按钮被点击时,会触发getSearch方法,获取到el-select被选中的值。

方式二:


    

对应的js代码


    new Vue({
        el: '#home',
        data: {
            options: [],
            value: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {
                this.options = [
                    {
                        value: '黄金糕',
                        label: '黄金糕'
                    }, {
                        value: '双皮奶',
                        label: '双皮奶'
                    }, {
                        value: '蚵仔煎',
                        label: '蚵仔煎'
                    }, {
                        value: '龙须面',
                        label: '龙须面'
                    }, {
                        value: '北京烤鸭',
                        label: '北京烤鸭'
                    }
                ]
            },
            selectChange() {
                console.log(this.value)
            }
        }
    })

select选项改变时,会调用selectChange方法。

如需要在下拉菜单中选中多个值中,可以在el-select标签中加入multiple选项,多选中标签的结果是一个数组。


    

7.Cascader 级联菜单组件用法

对应的js代码


    new Vue({
        el: '#home',
        data: {
            options: [],
            value: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {
                this.options = [
                    {
                        value: 'zhinan', label: '指南',
                        children: [
                            {
                                value: 'shejiyuanze', label: '设计原则',
                                children: [
                                    {value: 'yizhi', label: '一致'},
                                    {value: 'fankui', label: '反馈'},
                                    {value: 'xiaolv', label: '效率'},
                                    {value: 'kekong', label: '可控'}
                                ]
                            }, {
                                value: 'daohang', label: '导航',
                                children: [
                                    {value: 'cexiangdaohang', label: '侧向导航'},
                                    {value: 'dingbudaohang', label: '顶部导航'}
                                ]
                            }
                        ]
                    }, {
                        value: 'zujian', label: '组件',
                        children: [
                            {
                                value: 'basic', label: 'Basic',
                                children: [
                                    {value: 'layout', label: 'Layout 布局'},
                                    {value: 'color', label: 'Color 色彩'},
                                    {value: 'typography', label: 'Typography 字体'},
                                    {value: 'icon', label: 'Icon 图标'},
                                    {value: 'button', label: 'Button 按钮'}
                                ]
                            }, {
                                value: 'form', label: 'Form',
                                children: [
                                    {value: 'radio', label: 'Radio 单选框'},
                                    {value: 'checkbox', label: 'Checkbox 多选框'},
                                    {value: 'input', label: 'Input 输入框'},
                                    {value: 'input-number', label: 'InputNumber 计数器'},
                                    {value: 'select', label: 'Select 选择器'},
                                    {value: 'cascader', label: 'Cascader 级联选择器'},
                                    {value: 'switch', label: 'Switch 开关'},
                                    {value: 'slider', label: 'Slider 滑块'},
                                    {value: 'time-picker', label: 'TimePicker 时间选择器'},
                                    {value: 'date-picker', label: 'DatePicker 日期选择器'},
                                    {value: 'datetime-picker', label: 'DateTimePicker 日期时间选择器'},
                                    {value: 'upload', label: 'Upload 上传'},
                                    {value: 'rate', label: 'Rate 评分'},
                                    {value: 'form', label: 'Form 表单'}
                                ]
                            }, {
                                value: 'data', label: 'Data',
                                children: [
                                    {value: 'table', label: 'Table 表格'},
                                    {value: 'tag', label: 'Tag 标签'},
                                    {value: 'progress', label: 'Progress 进度条'},
                                    {value: 'tree', label: 'Tree 树形控件'},
                                    {value: 'pagination', label: 'Pagination 分页'},
                                    {value: 'badge', label: 'Badge 标记'}
                                ]
                            }, {
                                value: 'notice', label: 'Notice',
                                children: [
                                    {value: 'alert', label: 'Alert 警告'},
                                    {value: 'loading', label: 'Loading 加载'},
                                    {value: 'message', label: 'Message 消息提示'},
                                    {value: 'message-box', label: 'MessageBox 弹框'},
                                    {value: 'notification', label: 'Notification 通知'}
                                ]
                            }, {
                                value: 'navigation', label: 'Navigation',
                                children: [
                                    {value: 'menu', label: 'NavMenu 导航菜单'},
                                    {value: 'tabs', label: 'Tabs 标签页'},
                                    {value: 'breadcrumb', label: 'Breadcrumb 面包屑'},
                                    {value: 'dropdown', label: 'Dropdown 下拉菜单'},
                                    {value: 'steps', label: 'Steps 步骤条'}
                                ]
                            }, {
                                value: 'others', label: 'Others',
                                children: [
                                    {value: 'dialog', label: 'Dialog 对话框'},
                                    {value: 'tooltip', label: 'Tooltip 文字提示'},
                                    {value: 'popover', label: 'Popover 弹出框'},
                                    {value: 'card', label: 'Card 卡片'},
                                    {value: 'carousel', label: 'Carousel 走马灯'},
                                    {value: 'collapse', label: 'Collapse 折叠面板'}
                                ]
                            }
                        ]
                    },
                    {
                        value: 'ziyuan', label: '资源',
                        children: [
                            {value: 'axure', label: 'Axure Components'},
                            {value: 'sketch', label: 'Sketch Templates'},
                            {value: 'jiaohu', label: '组件交互文档'}
                        ]
                    }
                ]
            },
            getSearch() {
                console.log(this.value)
            }
        }
    })

可以先声明options为空数组,然后在init方法中为options数组赋值(可以异步请求后端数据,将后端响应数据赋值)

需要选中值就触发方法时,可以加@change="handleChange"选项来绑定触发方法

需指定长度时,可以加选项

其选中结果为一个数组类型,可以直接加索引获取选中的值

到此,关于“如何使用Link,Radio,Checkbox,Select,Cascader组件”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


本文名称:如何使用Link,Radio,Checkbox,Select,Cascader组件
网站路径:http://cdkjz.cn/article/ihopsh.html
返回首页 了解更多建站资讯
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220