Created
February 25, 2018 08:07
-
-
Save codehell/5aabc06b8a802ae4527c53e9820818c2 to your computer and use it in GitHub Desktop.
Imput vue componet
This file contains 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> | |
<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