【问题标题】:Deliver Html file using Vue.js and express.js使用 Vue.js 和 express.js 交付 Html 文件
【发布时间】:2018-10-07 13:04:50
【问题描述】:

我使用 Vue.js 作为前端,使用 express.js 作为后端。 当我使用 npm start 启动 express.js 服务器时,我想从 Vue 交付前端组件。

我正在使用 Vue 生成器和 Express 生成器,当我交付 index.html 文件时使用

    res.sendFile(path.join(__dirname + '/index.html'));

浏览器显示一个空站点,因为那里只写了。

    <div id="app"></div>

我想我必须先构建 index.html 文件,因为前端部分被分成不同的 Vue 组件(.vue 文件)

【问题讨论】:

    标签: javascript html node.js express vue.js


    【解决方案1】:

    您的快速服务器不仅要提供 index.html 文件,还要提供所有其他构建的 js 文件。如果您使用的是vue-cli,则必须在运行npm run build(生产模式构建)后提供在dist 文件夹中找到的所有文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-03
      • 2019-06-01
      • 2019-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-03
      • 1970-01-01
      相关资源
      最近更新 更多