中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

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

發布時間:2021-10-11 18:16:18 來源:億速云 閱讀:126 作者:iii 欄目:大數據

這篇文章主要介紹“如何使用Link,Radio,Checkbox,Select,Cascader組件”,在日常操作中,相信很多人在如何使用Link,Radio,Checkbox,Select,Cascader組件問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何使用Link,Radio,Checkbox,Select,Cascader組件”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

1.Link組件動態綁定URL

<div id="home" >
    <el-row :gutter="40">
        <el-col :span="16">
            <el-form label-width="100px">
                <el-link :href="href" target="_blank">默認鏈接</el-link>
            </el-form>
        </el-col>
    </el-row>
</div>

對應的js代碼

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

2.Radio 用法

<el-radio-group v-model="addType" @change="radioChange">
    <el-radio :label="1" >備選項1</el-radio>
    <el-radio :label="2" >備選項2</el-radio>
    <el-radio :label="3" >備選項3</el-radio>
</el-radio-group>

對應的js代碼

<script type="text/javascript">
    new Vue({
        el: '#home',
        data: {
            addType: null       # 必須聲明綁定的值,否則頁面無法渲染
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            radioChange() {
                console.log(this.addType)
            }
        }
    })
</script>

當選項被選中時,會調用radioChange方法。

3.Checkbox用法

方式一:

<el-input-number v-model="num" @change="handleChange" :min="1" :max="10" label="描述文字"></el-input-number>

對應的js代碼

<script type="text/javascript">
    new Vue({
        el: '#home',
        data: {
            num: ''
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            checkChange() {
                console.log(this.num)
            }
        }
    })
</script>

當標簽中的值改變時,會調用handleChange方法。

方式二:

<el-input-number v-model="num" :min="1" :max="10" label="描述文字"></el-input-number>
<el-button type="success" @click="getSearch">搜索</el-button>

對應的js代碼

<script type="text/javascript">
    new Vue({
        el: '#home',
        data: {
            num: '',
        },
        mounted() {
            this.init()
        },
        methods: {
            init() {

            },
            getSearch() {
                console.log(this.num)
            }
        }
    })
</script>

當搜索按鈕被點擊時,會觸發getSearch方法,獲取到num的值。

4.Select 用法

方式一:

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

<el-select v-model="value" placeholder="請選擇">
    <el-option v-for="item in options" :key="item.value" :value="item.value"></el-option>
</el-select>
<el-button type="success" @click="getSearch">搜索</el-button>

對應的js代碼

<script type="text/javascript">
    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)
            }
        }
    })
</script>

可以先聲明options為空數組,然后在init方法中為options數組賦值(可以異步請求后端數據,將后端響應數據賦值)

當搜索按鈕被點擊時,會觸發getSearch方法,獲取到el-select被選中的值。

方式二:

<el-select v-model="value" placeholder="請選擇" @change="selectChange">
    <el-option v-for="item in options" :key="item.value" :value="item.value"></el-option>
</el-select>

對應的js代碼

<script type="text/javascript">
    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)
            }
        }
    })
</script>

select選項改變時,會調用selectChange方法。

如需要在下拉菜單中選中多個值中,可以在el-select標簽中加入multiple選項,多選中標簽的結果是一個數組。

<el-select v-model="value" multiple placeholder="請選擇" @change="selectChange">
    <el-option v-for="item in options" :key="item.value" :value="item.value"></el-option>
</el-select>

7.Cascader 級聯菜單組件用法

<el-cascader v-model="value" :options="options" @change="handleChange" ></el-cascader>

對應的js代碼

<script type="text/javascript">
    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)
            }
        }
    })
</script>

可以先聲明options為空數組,然后在init方法中為options數組賦值(可以異步請求后端數據,將后端響應數據賦值)

需要選中值就觸發方法時,可以加@change="handleChange"選項來綁定觸發方法

需指定長度時,可以加選項

其選中結果為一個數組類型,可以直接加索引獲取選中的值

到此,關于“如何使用Link,Radio,Checkbox,Select,Cascader組件”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

汽车| 马鞍山市| 闸北区| 新兴县| 威宁| 陆良县| 昭平县| 华亭县| 南江县| 东阿县| 池州市| 南昌市| 禄劝| 岳池县| 磐石市| 晋州市| 株洲市| 黄浦区| 江达县| 宜丰县| 绥阳县| 桦甸市| 滨州市| 康定县| 辉南县| 连云港市| 定结县| 姜堰市| 鹤壁市| 什邡市| 昌平区| 昆山市| 金秀| 中方县| 长丰县| 襄垣县| 聊城市| 顺昌县| 新平| 龙陵县| 北宁市|