0.4.2 • Published 7 years ago
@hanhdt/vue-simpleform v0.4.2
vue-simpleform
A Vue component for building form
Installation
NPM
$npm install --save @hanhdt/vue-simpleformYARN
$yarn add @hanhdt/vue-simpleformCDN
https://unpkg.com/@hanhdt/vue-simpleform@0.4.0/dist/vue-simpleform.umd.jsProvided Components
SimpleForm: This is main component which will generally create HTMLformtagFormInput: The form input component utilityLoading: A loading component is called when the form is busy
Usages
Props descriptions
SimpleFormtitle: This is displayed as Form's title in the<h2>elementoperation: The asynchronous function called when the form is submitted. It is returned in a promise-stylevalid: A Boolean to prevent calling the operation if the form is not valid
FormInputname: form input's nameinputClass: the customed classplaceholder: input's placeholdertype: type of input tag rendered
Using SimpleForm component in existing Vue project
Import package
in the main.js, import the package as a global component.
import '@hanhdt/vue-simpleform'Add SimpleForm component into *.vue template
<SimpleForm
class="form"
:title="title"
:operation="() => console.log('form submit')"
:valid="valid">
<!-- FORM TEXT INPUT -->
<FormInput
name="title"
v-model="title"
placeholder="Short title (max 100 chars)"
maxlength="100"
:text="title"
required />
<!-- FORM TEXTAREA INPUT -->
<FormInput
type="textarea"
name="description"
v-model="description"
placeholder="Describe your problem in details"
rows="4" />
<template slot="actions">
<!-- BUTTON ACTIONS -->
<button type="submit">
Submit
</button>
</template>
</SimpleForm>