I am using CoreUI template for VueJS version but i am not sure how to get the CInput value from this link: https://coreui.io/vue/demo/3.0-beta.1/#/forms/basic-forms,
I want to binding the input value just like this: https://v2.vuejs.org/v2/guide/forms.html#Text
Here is the code, i have used v-model but it looks like it is unable to work:
<template>
<div>
<p style="white-space: preline;">{{message}}</p>
<CForm>
<CInput
v-model="message"
label="Input is valid"
valid-feedback="Input is valid."
invalid-feedback="Please provide at least 4 characters."
value="Valid value"
:is-valid="validator"
/>
<CInput
label="Input is invalid"
valid-feedback="Thank you :)"
invalid-feedback="Please provide at least 4 characters."
:is-valid="validator"
/>
</CForm>
</div>
</template>
<script>
export default {
methods: {
validator(val) {
return val ? val.length >= 4 : false
}
}
}
</script>
v-model
isn't available with CInput
component. According to their docs, you can use the events (update:value
, input
and change
) to update your component data. Example:
<template>
<div>
<p style="white-space: preline;">{{message}}</p>
<CForm>
<CInput
label="Input is valid"
valid-feedback="Input is valid."
invalid-feedback="Please provide at least 4 characters."
:value="message"
@input="message = $event.target.value"
:is-valid="validator"
/>
<CInput
label="Input is invalid"
valid-feedback="Thank you :)"
invalid-feedback="Please provide at least 4 characters."
:is-valid="validator"
/>
</CForm>
</div>
</template>
<script>
export default {
data () {
return {
message: "",
}
},
methods: {
validator(val) {
return val ? val.length >= 4 : false
}
}
}
</script>