Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 749 Bytes

setSelected.md

File metadata and controls

27 lines (17 loc) · 749 Bytes

setSelected()

option 要素を選択します。そして、 v-model に束縛されているデータを更新します。

  • 例:
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = shallowMount(Foo)
const options = wrapper.find('select').findAll('option')

options.at(1).setSelected()
  • 注:

v-model を経由して option.element.selected = true; parentSelect.trigger('input') で state に値をセットしようとすると、 v-model はトリガされません。 v-modelchange イベントでトリガされます。

option.setSelected() は以下のコードのエイリアスです。

option.element.selected = true
parentSelect.trigger('change')