Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue/vuetify v-switch: what is input-value?

Can someone explain to me exactly what the input-value attribute does on the v-switch component?

I think it has something to due with using the component with vuex, when you cannot use v-model directly.

It seems to be working for me, but I don't understand it exactly.

You can see the attribute here: https://vuetifyjs.com/en/components/selection-controls#api

Where it is described as: "The v-model bound value".

(I originally found the attribute in an example somehere.)

like image 982
mtyson Avatar asked Jul 23 '18 18:07

mtyson


People also ask

What is V content Vuetify?

There are 2 primary layout components in Vuetify, v-app and v-main . The v-app component is the root of your application and a direct replacement for the default Vue entrypoint, <div id="app"> . The v-main component is a semantic replacement for the main HTML element and the root of your application's content.

How do I add components to Vuetify?

Simply include the Vuetify css file in your index. html or import the actual stylus file or the minified css. Some components like the date picker use Material Icons. The easiest way to include them is to add a link tag to your index.

Does vue3 support Vuetify?

The current version of Vuetify does not support Vue 3.

What is V text Vue?

v-text works by setting the element's textContent property, so it will overwrite any existing content inside the element. If you need to update the part of textContent , you should use mustache interpolations instead. Example.


1 Answers

input-value behaves like a default value attribute that you would expect in other components.
Normally v-model is syntax sugar for :value="value" :input="$emit('input', $event.target.value)", but we can change it.

from selectable.js:

model: {
  prop: 'inputValue',
  event: 'change'
},

So the above lines (see vue docs) make your v-model bind to input-value instead of value likely because some components i.e. checkbox (which v-switch uses) have value attribute reserved for something else.

So value attribute is then used to set the value which will be represented when the component is checked.
And in v-switch case v-model is syntax sugar for something like :input-value="value" @change="value = $event"

Codepen

like image 83
Traxo Avatar answered Sep 17 '22 13:09

Traxo