Integration with the Feathers framework for Vue.js
feathers-vue
Feathers is a minimalist real-time web framework written in JavaScript. Feathers-Vue is a plugin for Vue.js that integrates it with Feathers.
NOTE: It's supposed to be compatible both with Vue 1.x and 2.x. It requires IE9+ or Safari 5+
Install
npm install feathers-vue --save
Usage
-- -------------------- ---- ------- -- ------- --- --- -- -------- ------ ----- -------- - --------------------------- ----- ----- - -------------------------- ----- -------- - ------------------------------------ ----- -- - ---------------------------- ----- ------ - ---------- -------------------------------------------------- -------------------- -- ------- -- -- - -------- ------ ----- --- - --------------- ----- ----------- - ------------------------ -- --- ---- -- -- -------------------- -------
Now in every component you get a new property called $services
, which allows you to interact with all of your Feathers services:
this.$services.messages.find() // or this.$services.messages.create(...)
To subscribe on the events your services generate, you just need to use a separate feathers
section in your component:
-- -------------------- ---- ------- ------ ------- - ------ - ------ - --- - -- -------- - --- - --------- - -- ---- -- --- ------- --------- - -- ---- -- --- ---------- --- --- ---------- ------- ------------- - --- -- ------------- - --- - - - -
feathers-vue does all the clean up before your component is destroyed (using the removeListener
function).
In case you need to do something more complex, there is a $feathers
property for that:
this.$feathers.service('messages').on(...)
License
HomePage
https://github.com/xwa130/feathers-vue#readme
Repository
git://github.com/xwa130/feathers-vue.git
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/6005603d81e8991b448de693