简体   繁体   中英

Deliver Html file using Vue.js and express.js

i am using Vue.js as frontend and express.js as Backend. When i start the express.js server with npm start, i would like to deliver the frontend component from Vue.

I am using Vue generator & Express generator, when i deliver the index.html file with

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

the browser shows an empyt site, because there is only written.

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

I think i have to build the index.html file first, because the frontend part is divided up in different Vue components (.vue files)

Your express server has to serve not only the index.html file but also all the other built js files. If you are using vue-cli , you have to serve all the files that you find in the dist folder after you run npm run build (production mode build).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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