@netsells/vue-with-prop-proxy
Proxy a prop in Vue to make it easier to set it if using v-model or the sync modifier
Last updated a year ago by sam.boylett .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @netsells/vue-with-prop-proxy 
SYNC missed versions from official npm registry.

npm version Build Status codecov Mutation testing badge

Vue With Prop Proxy

A mixin to make it easy to bind prop values to models or synced props on child components

Usage

You can pass a string, an object, or an array of either to configure your proxies. The second argument is the options and lets you change the suffix for proxies if just passed a string.

import withPropProxy from '@netsells/vue-with-prop-proxy';

export default {
    mixins: [withPropProxy('value')],

    props: ['value'],

    template: `<input v-model="valueProxy" />`
}

Changing the suffix

import withPropProxy from '@netsells/vue-with-prop-proxy';

export default {
    mixins: [withPropProxy('value', { suffix: 'Model' })],

    props: ['value'],

    template: `<input v-model="valueModel" />`
}

Using multiple props

import withPropProxy from '@netsells/vue-with-prop-proxy';

export default {
    mixins: [withPropProxy(['value', 'name'])],

    props: ['value', 'name'],

    template: `
        <div>
            <input v-model="valueProxy" />
            <input v-model="nameProxy" />
        </div>
    `
}

Using an object

import withPropProxy from '@netsells/vue-with-prop-proxy';

export default {
    mixins: [withPropProxy({ prop: 'value', via: 'model' })],

    props: ['value'],

    template: `<input v-model="model" />`
}

Current Tags

  • 0.2.0                                ...           latest (a year ago)

4 Versions

  • 0.2.0                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (24)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |