vue-decorator-components

0.1.1 • Public • Published

vue-decorator-components

This is a demo , just complete base function

Use decorator component with class-validator like this:

import { Length, validate } from 'class-validator'
import { InputComponent, PasswordComponent, ButtonComponet } from './components'
import { BaseComponent } from './decorators/createComponent'

class Form extends BaseComponent {
	@InputComponent({ label: 'username' })
	@Length(4, 20)
	username: string = ''

	@PasswordComponent({ label: 'password', type: 'password' })
	@Length(4, 20)
	password: string = ''

	@ButtonComponet()
	login = () => {
		validate(this).then(errors => {
			console.log(this.username, this.password)
			if (errors.length > 0) {
				console.log('validation failed. errors: ', errors)
			} else {
				console.log('validation succeed')
			}
		})
	}
}

const loginForm = new Form().createInstanceComponent()

export default loginForm

Untitled

will create this

Readme

Keywords

none

Package Sidebar

Install

npm i vue-decorator-components

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

27.4 kB

Total Files

19

Last publish

Collaborators

  • andspark