【发布时间】:2019-10-29 01:40:54
【问题描述】:
我已经使用 VueCLI 构建了我的项目网站,所以现在我想在我的服务器 Node.js 上部署我的应用程序。 问题是 : - 当我运行命令 build 以获取 dist 文件夹并将其放入我的 nodejs 服务器时,我无法使用我的 vue 路由器,因为例如:http://server.com/page1 它向服务器发出请求但我只想访问该页面在带有Vue路由器的应用程序中。
'这是一个使用vue router的单页网站'
我的 node.js 服务器示例:
const express = require('express');
const path = require('path');
const app = express();
app.use('/static', express.static(path.join(__dirname, '/dist')))
app.get('/',(req,res)=>{
res.sendFile(__dirname+'/static/index.html')
})
app.listen('3000',()=>{
console.log("listen on port 3000");
})
/site.com
/site.com/dist
/site.com/dist/css
/site.com/dist/js
/site.com/dist/index.html
/site.com/index.js //server nodejs
我希望能够访问我的 vue 路由器网站的内部页面。 当我在 url 中询问页面时,它会询问服务器。
【问题讨论】:
标签: node.js vue.js vue-cli vue-cli-3