Skip to content

Instantly share code, notes, and snippets.

@drakakisgeo
Created November 20, 2017 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakakisgeo/39a26b7e7904831d7441bca34a0c10e8 to your computer and use it in GitHub Desktop.
Save drakakisgeo/39a26b7e7904831d7441bca34a0c10e8 to your computer and use it in GitHub Desktop.
Example of how to build a Vue.js input component
<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