Skip to content

Instantly share code, notes, and snippets.

@codehell
Created February 25, 2018 08:07
Show Gist options
  • Save codehell/5aabc06b8a802ae4527c53e9820818c2 to your computer and use it in GitHub Desktop.
Save codehell/5aabc06b8a802ae4527c53e9820818c2 to your computer and use it in GitHub Desktop.
Imput vue componet
<template>
<div class="form-group" :class="{ 'has-error': hasError }">
<div class="col-md-6">
<input :id="name"
:type="type"
class="form-control"
:name="name"
:value="value"
:required="required"
:autofocus="autoFocus"
:placeholder="placeholder"
>
<span class="help-block" v-if="hasError">
<strong>{{ error }}</strong>
</span>
</div>
</div>
</template>
<script>
export default {
name: 'codehell-input',
props: {
'label': {
type: String,
default: ''
},
'type': {
type: String,
default: ''
},
'name': {
type: String,
default: ''
},
'value': {
type: String,
default: ''
},
'required': {
type: Boolean,
default: false
},
'autoFocus': {
type: Boolean,
default: false
},
'error': {
type: String,
default: ''
},
'placeholder': {
type: String,
default: ''
},
},
computed: {
hasError () {
return this.error.length !== 0
}
}
}
</script>
<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment