UNPKG

hae

Version:

Mobile web UI based on Vux

32 lines (30 loc) 667 B
const WebSocket = function (address) { this.send = function (message) { this.websocket.send(message); } this.close = function () { this.weboscket.close(); } return (function () { if ('WebSocket' in window) { return { websocket: new WebSocket(address), code: 1, msg: 'success' } } else { return { websocket: null, code: 0, msg: 'fail, your browser does not support websockt' } } })(address); } export default { install (Vue) { Vue.prototype.$webSocket = WebSocket; Vue.webSocket = WebSocket }, $webSocket: WebSocket }