Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 590 Bytes

setSelected.md

File metadata and controls

24 lines (16 loc) · 590 Bytes

setSelected()

Selects a option element.

When you try to set the value to state via v-model by option.element.selected = true; parentSelect.trigger('input'), v-model is not triggered. v-model is triggered by change event.

option.setchecked(checked) is an alias of the following code.

option.element.selected = true
parentSelect.trigger('change')
  • Example:
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()