选择选项后如何使用element-ui和vuejs触发“选择”的模糊事件?

Mah*_*ngh 5 vue.js element-ui

我正在使用 element-ui 和 vuejs。我有一个看起来像这样的选择元素

<el-form-item label="City" prop="city">
     <el-select 
            v-model="form.city" 
            multiple 
            filterable
            remote
            auto-complete = "address-level2"
            no-match-text = "No data found"
            :remote-method = "remoteMethod"
            :loading = "loading"
            placeholder="Select City">
          <el-option
            v-for = "(item,index) in cities"
            :key = "index"
            :label = "item.name"
            :value = "item.key"
          ></el-option>
     </el-select>
</el-form-item>
Run Code Online (Sandbox Code Playgroud)

现在我想在用户选择一个选项后触发这个选择的模糊事件,以便下拉选项折叠。

这是我的远程方法

remoteMethod: _.throttle(function(query) {
        this.loading = true;
        axios({
            method: 'get',
            url: someUrl
        }).then(response =>{
            if(response.data.status === false){
                this.$notify.error({
                    title: 'Error',
                    message: response.data.message
                });
            }
            else if(response.data.status === true && response.data.data.length != 0){
                this.loading = false;
                this.cities = response.data.data;
            }
        })            
    }, 1500),
Run Code Online (Sandbox Code Playgroud)

jac*_*cky 4

您可以在组件上设置 ref 属性,就像 ref="select1" 一样

然后你可以通过this.$refs调用focus或blur方法

就像: this.$refs.select1.focus()

请参阅http://element.eleme.io/#/en-US/component/select