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

```js
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 组件:获取选中项的索引和对象

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

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