Created
November 20, 2017 12:31
-
-
Save drakakisgeo/39a26b7e7904831d7441bca34a0c10e8 to your computer and use it in GitHub Desktop.
Example of how to build a Vue.js input component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<select :value="value" :name="name" class="form-control" v-on:input="updatevalue($event.target.value)" ref="input"> | |
<slot></slot> | |
</select> | |
</template> | |
<script> | |
export default { | |
props:['value','name'], | |
methods: { | |
updatevalue: function(value){ | |
this.$refs.input.value = value; | |
// Emit the number value through the input event | |
this.$emit('input', value); | |
} | |
} | |
} | |
</script> | |
===================== | |
<inputcomponent v-model="modelname"></inputcomponent> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment