Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/midnightsuyama/vue-assign-model
Automatically assign elements value to model for Vue.js
https://github.com/midnightsuyama/vue-assign-model
vue
Last synced: about 1 month ago
JSON representation
Automatically assign elements value to model for Vue.js
- Host: GitHub
- URL: https://github.com/midnightsuyama/vue-assign-model
- Owner: midnightSuyama
- Created: 2017-08-12T14:53:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-14T17:31:53.000Z (over 7 years ago)
- Last Synced: 2024-10-11T00:22:09.414Z (2 months ago)
- Topics: vue
- Language: JavaScript
- Size: 42 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vue-assign-model
[![npm version](https://badge.fury.io/js/vue-assign-model.svg)](https://badge.fury.io/js/vue-assign-model)
[![CircleCI](https://circleci.com/gh/midnightSuyama/vue-assign-model.svg?style=shield)](https://circleci.com/gh/midnightSuyama/vue-assign-model)Automatically assign elements value to model for Vue.js
## Installation
$ npm install vue-assign-model
## Usage
```javascript
import Vue from 'vue'
import VueAssignModel from 'vue-assign-model'Vue.use(VueAssignModel)
```Before Vue rendering, `value`, `checked` or `selected` attributes of elements with `v-model` is automatically assigned to Vue model.
## Example
### Text
```html
```
```javascript
/* assigned model */
data: {
text: "edit me"
}
```### Multiline text
```html
add multiple lines
``````javascript
/* assigned model */
data: {
textarea: "add multiple lines"
}
```### Checkbox
```html
```
```javascript
/* assigned model */
data: {
checked: true
}
```### Multiple checkboxes
```html
```
```javascript
/* assigned model */
data: {
checkedNames: ["Mike"]
}
```### Radio
```html
```
```javascript
/* assigned model */
data: {
picked: "Two"
}
```### Select
```html
Please select one
A
B
C```
```javascript
/* assigned model */
data: {
selected: "C"
}
```### Multiple select
```html
A
B
C```
```javascript
/* assigned model */
data: {
selectedMultiple: ["B", "C"]
}
```### Other
JSON of `data-vue-model` is assigned to Vue model.
```html
-
{{ item }}
```
```javascript
/* assigned model */
data: {
items: ["Foo", "Bar"]
}
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/midnightSuyama/vue-assign-model.
## License
The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).