iView Select

iView Select教程,请移步传送门click

1.iView官网实例

<template>
    <Row>
        <Col span="12" style="padding-right:10px">
            <Select
                v-model="model13"
                filterable
                remote
                :remote-method="remoteMethod1"
                :loading="loading1">
                <Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option>
            </Select>
        </Col>
    </Row>
</template>
<script>
    export default {
        data () {
            return {
                model13: '',
                loading1: false,
                options1: [],
                model14: [],
                loading2: false,
                options2: [],
                list: ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New hampshire', 'New jersey', 'New mexico', 'New york', 'North carolina', 'North dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode island', 'South carolina', 'South dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West virginia', 'Wisconsin', 'Wyoming']
            }
        },
        methods: {
            remoteMethod1 (query) {
                if (query !== '') {
                    this.loading1 = true;
                    setTimeout(() => {
                        this.loading1 = false;
                        const list = this.list.map(item => {
                            return {
                                value: item,
                                label: item
                            };
                        });
                        this.options1 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);
                    }, 200);
                } else {
                    this.options1 = [];
                }
            }
    }
</script>

Notes

Notice: If not template/render mode, you need to usei-select, i-option.

Select events

Event Name Description Return Value
on-change Emitted when selected Optionchange.It will return value. See the label-in-value property if need return label The current selected item.
on-query-change Emitted when query word is changed. query
on-clear Emitted when click clear button. -
on-open-change Emitted when dropdown show or hide. true / false

vue 的原生select,使用的是change事件去触发,select change事件,而在iView中,使用的是on-change事件

如下

                        <div class="select">
                            <i-select style="width:100px" v-model="type" @on-change="changeValue(type,'测试')">
                                <i-option :value="'申请'">申请</i-option>
                                <i-option :value="'申请'">授权</i-option>
                            </i-select>
                        </div>

<script>
        changeValue(type, option) {
           console.log('type is: %s, option is: %s',type,option)
        }
</script>

在没看iview api之前,使用v-on:change 事件触发select无效,所以还得使用iView的on-change事件才能触发

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • iView Select标签在使用搜索功能时 , 有时候会出现数组里有数据但是并未展示的问题. 原因如下: :vl...
    ErHu丶阅读 10,421评论 0 1
  • 在使用iview的过程,碰到一个数据列表卡死的问题。当时因为页面上的select比较多,排除也比较慢,最终定位到了...
    Susanna_2c72阅读 8,949评论 0 3
  • 这篇笔记主要包含 Vue 2 不同于 Vue 1 或者特有的内容,还有我对于 Vue 1.0 印象不深的内容。关于...
    云之外阅读 10,474评论 0 29
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,180评论 0 10
  • 什么是闭包?闭包的优缺点? 闭包(closure)是javascript的一大难点,也是它的特色。很多高级应用都要...
    妙味课堂King阅读 1,441评论 0 0

友情链接更多精彩内容