可以在Vue Select组件的模板中添加一个监听change事件的方法:

<template>
  <div>
    <v-select v-model="selectedItem" :options="options" @change="handleSelectChange"></v-select>
  </div>
</template>

然后在Vue实例中定义handleSelectChange方法:

export default {
  data() {
    return {
      selectedItem: null,
      options: [
        { value: 'option1', label: 'Option 1' },
        { value: 'option2', label: 'Option 2' },
        { value: 'option3', label: 'Option 3' }
      ]
    };
  },
  methods: {
    handleSelectChange(index, item) {
      console.log('Selected index:', index);
      console.log('Selected item:', item);
    }
  }
};

在handleSelectChange方法中,可以获取到当前选中的选项的索引和对象。可以根据需要对选项进行操作

vue Select组件 有一个change的方法定义一个change的方法然后 获取index和item

原文地址: https://www.cveoy.top/t/topic/cjBC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录