0.1.1 • Published 7 years ago
vue-sails v0.1.1
vue-sails
Sails is the most popular MVC framework for Node.js. Vue-Sails is a plugin for Vue.js that integrates it with Sails.
NOTE: It's supposed to be compatible both with Vue 1.x and 2.x. It requires IE9+ or Safari 5+
Install
npm install vue-sails --save
Usage
// Include and set up Sails client
const socketIOClient = require('socket.io-client');
const sailsIOClient = require('sails.io.js');
const io = sailsIOClient(socketIOClient);
// Additional Sails.io.js configuration
// io.sails.url = 'http://localhost:1337';
// io.sails.environment = process.env.NODE_ENV || 'development';
// Include vue-sails as a CommonJS module
const Vue = require('vue');
const vueSails = require('vue-sails');
// Enable the plugin globally
Vue.use(vueSails, io)
Now in every component you get a new property called $io
, which allows you to interact with the Sails socket client:
this.$io.socket.get(url, data, function (resData, jwres){
// ...
});
// or
this.$io.socket.on(eventIdentity, function (msg) {
// ...
});