vue-provider

1.1.0 • Public • Published

vue-provider

NPM version NPM downloads CircleCI donate

How does it work?

provide/inject.

Install

yarn add vue-provider

Usage

import Vue from 'vue'
import Provider from 'vue-provider'

const Root = {
  render() {
    return <Provider msg="hello">
      <Child />
    </Provider>
  }
}

const Child = {
  inject: ['msg'],
  render() {
    return <button>{this.msg}</button>
  }
}

new Vue({
  el: '#root',
  render: h => h(Root)
})

It renders:

<button>hello</button>

Create provider

By default the Provider component name is Provider, however you can use a custom one:

import { createProvider } from 'vue-provider'

const ThemeProvider = createProvider('ThemeProvider')

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-provider © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

Readme

Keywords

none

Package Sidebar

Install

npm i vue-provider

Weekly Downloads

2

Version

1.1.0

License

MIT

Last publish

Collaborators

  • rem