简体   繁体   English

什么是 websockets,我应该使用什么 js 框架

[英]What's websockets and what js framework should I use

I'm very new to the Java Script world , I use Laravel already for my backend but when it came to the websockets part I kinda got messy , because when I looked for websockets I have read that they all are depending on Node JS for real time apps like chat apps but also I have seen a tutorial making a chat app in Vue Js & laravel echo only without using node js ,我对 Java Script 世界很陌生,我已经将 Laravel 用于我的后端,但是当谈到 websockets 部分时,我有点混乱,因为当我寻找 websockets 时,我读到它们都真正依赖于 Node JS时间应用程序,如聊天应用程序,但我也看过一个教程,仅在不使用节点 js 的情况下,在 Vue Js 和 laravel echo 中制作聊天应用程序,

now the messy part for me is , If I want to learn socket.io (for example) should I learn Node Js first ?现在对我来说凌乱的部分是,如果我想学习 socket.io(例如),我应该先学习 Node Js 吗? And is Vue js an alternative for the socketio ? Vue js 是 socketio 的替代品吗? and How about the ajax ?和 ajax 怎么样? isn't it able to do the same performance ?它不能做同样的表现吗?

I'm sorry but It's kinda messy for me , I have looked for that but it is still messy for me , thanks for advance对不起,这对我来说有点乱,我已经找过了,但对我来说仍然很乱,谢谢你的提前

If I want to learn socket.io (for example) should I learn Node Js first?如果我想学习socket.io(例如),我应该先学习Node Js吗?

Yes.是的。 Since Socket.IO is a Node.js package, it's kind of a pre-requisite to learn Node.由于Socket.IO是一个 Node.js 包,因此它是学习 Node 的先决条件。 It's one of the easiest tools to learn though, so don't be intimidated.不过,它是最容易学习的工具之一,所以不要被吓倒。

And is Vue js an alternative for the socketio? Vue js 是 socketio 的替代品吗?

No. Vue.js is front-end framework, which means it's used to build the part of the website you actually see.不。Vue.js 是前端框架,这意味着它用于构建您实际看到的网站部分。 Socket.io is a package (or framework) that enables bi-directional communication between the front-end and the back-end of your application. Socket.io 是一个包(或框架),它支持应用程序前端和后端之间的双向通信。 You can use it for example to build a chat application.例如,您可以使用它来构建聊天应用程序。

How about the ajax ?阿贾克斯怎么样? isn't it able to do the same performance?它不能做同样的表现吗?

No. Ajax is short for Asynchronous JavaScript And XML .不是。Ajax 是Asynchronous JavaScript And XML 的缩写。 Which basically means that you use Ajax requests from the front-end to the back-end.这基本上意味着您使用从前端到后端的 Ajax 请求。 The difference here is that Websockets/Socket.IO gives you the bi-directional communication that Ajax lacks.这里的区别在于 Websockets/Socket.IO 为您提供了 Ajax 所缺乏的双向通信。 You don't need Socket.IO for all communication though虽然您不需要 Socket.IO 进行所有通信

I agree with everything exposed in the accepted answer except that Vuejs isn't an alternative.我同意接受的答案中公开的所有内容,除了 Vuejs 不是替代方案。 It is true that vuejs is a javascript framework to create frontends, but, if you have a nodejs server with a socketio server, you need a client (frontend) which must be able to communicate through socketio. vuejs 确实是一个用于创建前端的 javascript 框架,但是,如果您有一个带有 socketio 服务器的 nodejs 服务器,则您需要一个必须能够通过 socketio 进行通信的客户端(前端)。 You can see this by yourself here , this is one of the most common vue wrappers library to use socketio from vuejs.你可以在这里自己看到这个,这是最常见的 vue 包装库之一,用于使用 vuejs 中的 socketio。 I hope this could help我希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该使用什么编码来在 node.js 中“gzuncompress()”? - What's the encoding should I use to “gzuncompress()” in node.js? 我应该知道的顶级js库/框架/工具是什么? - what are the top js lib/framework/tool i should know? 在没有库的情况下在Node.js中使用websockets的简单方法是什么? - What is a simple way to use websockets in Node.js WITHOUT a library? 这两者之间有什么区别,我应该使用哪一个? - What's the difference between these two and which should I use? 我应该使用什么活动? - What event should I use? 我应该使用什么协议以及它的文档是什么? - What protocol should I use and what are the docs for it? 我应该为简单的 HTML5 + jQuery 应用程序使用什么 JavaScript UI 测试框架? - What JavaScript UI testing framework should I use for a simple HTML5 + jQuery app? 用于聊天的协议是什么? webRTC或Websockets - What Protocol to use for chat? webRTC or Websockets 如果我在本地运行Node.js服务器,我究竟应该在http请求中使用什么作为参数'url'? - What exactly should I use as an argument 'url' in http request if i run Node.js server locally? 我应该在这个练习中使用 JavaScript 中的哪个函数? - What function in JavaScript should I use for this exercise?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM