简体   繁体   English

如何为网络上的其他计算机提供vue项目

[英]How to serve a vue project to other computers on the network

I am very new to vue.js.我对 vue.js 很陌生。

I have made a couple of small projects and I would like to be sure I understand how I actually serve a vue project to other users at this point.我已经做了几个小项目,我想确定我现在了解我实际上是如何为其他用户提供 vue 项目的。

Of course, I know I can type 'npm run serve' in my project directory and it will serve it to localhost:80XX.当然,我知道我可以在我的项目目录中输入“npm run serve”,它会将它提供给 localhost:80XX。 That is what I've been doing since I started working with vue a couple days ago.这就是我几天前开始使用 vue 以来一直在做的事情。 However, when I do this the network line under the 'local: localhost:8080' just reads 'network: unavailable', so I am obviously not broadcasting on anything another computer can connect to and receive from.但是,当我执行此操作时,'local: localhost:8080' 下的网络行只是读取'network: 不可用',所以我显然没有在另一台计算机可以连接和接收的任何内容上进行广播。

How does this basically work?这基本上是如何工作的? Do I have to build it with npm run build and then use firebase or something similar to broadcast the contents of my dist folder out to the user?我是否必须使用 npm run build 构建它,然后使用 firebase 或类似的东西将我的 dist 文件夹的内容广播给用户? Searching online produced some pretty confusing results, I ended up with more questions than answers.在线搜索产生了一些非常令人困惑的结果,我最终得到的问题多于答案。

I basically would just like to show my coworkers what I have made with vue, what is the way to do this without taking a shortcut?我基本上只是想向我的同事展示我用 vue 所做的事情,有什么方法可以做到这一点而不走捷径? I would like to do this in a way that I will be able to understand in the future how to do this with a fully fledged project.我想以一种我将来能够理解如何通过一个成熟的项目来做到这一点的方式来做到这一点。

Thank you!谢谢!

edit: if there is a tutorial or a link that discusses this directly, please feel free to refer me to it!编辑:如果有直接讨论这个的教程或链接,请随时参考我! I was unable to find this being discussed at the level I'm at.我无法找到在我所处的级别对此进行讨论。

According to the documentation , the default HOST that Vue binds to, is 0.0.0.0 , which means that anyone in your network can see your server.根据 文档,Vue 绑定到的默认 HOST 是0.0.0.0 ,这意味着您网络中的任何人都可以看到您的服务器。

What you can do is find your network ip address, and share with others.您可以做的是找到您的网络IP地址,并与他人共享。

To do so, you can do, in Windows:为此,您可以在 Windows 中执行以下操作:

  1. Open your terminal打开你的终端
  2. Type:类型:
ipconfig 
  1. Grab the IPv4 address of your network获取网络的IPv4地址
  2. Share the link with your colleagues in the form: http://<IP_ADDRESS>:8080以以下形式与您的同事分享链接: http://<IP_ADDRESS>:8080

This way, they can connect to your running develop instance.这样,他们就可以连接到您正在运行的开发实例。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM