I created a new vue project with the CLI and want to deploy it. Based on this documentation
https://router.vuejs.org/guide/essentials/history-mode.html#html5-history-mode
I added the history mode to the router. After running npm run build
I took the example code for a static native Node server
https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
const http = require('http')
const fs = require('fs')
const httpPort = 3000
http.createServer((req, res) => {
fs.readFile('../base/index.html', 'utf-8', (err, content) => {
if (err) {
throw err;
}
res.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8'
})
res.end(content)
})
}).listen(httpPort, () => {
console.log('Server listening on: http://localhost:%s', httpPort)
})
So when navigating to localhost:3000
the vue project seems to load correctly
but I have a blank page with two errors
When I click on those js files it shows me the content of the index.html file. Obviously js is not able to understand this html content. How can I fix that problem?
Server will not send the whole vue app at once.
It request those file from server, but you haven't initialized server to find those files.
So, need to add static files.
https://expressjs.com/en/starter/static-files.html
You can take reference from here
I want to trying adding class using javascript, I know there is a lot of topic about this in stackoverflow but some of them is too complicated for me to understand, let say I have this simple code ...
I want to trying adding class using javascript, I know there is a lot of topic about this in stackoverflow but some of them is too complicated for me to understand, let say I have this simple code ...
I have two variables with JSON files. The first is a list of keys looks like this: keylist = ["key1","key2","key3"] The second one is generated from a database and looks like this: data = { "...
I have two variables with JSON files. The first is a list of keys looks like this: keylist = ["key1","key2","key3"] The second one is generated from a database and looks like this: data = { "...
I have an array like below and I want to extract objects and sub-array and create a new array if the selected object value is true menu: [ { category_name: "snacks", selected: true ...
I have an array like below and I want to extract objects and sub-array and create a new array if the selected object value is true menu: [ { category_name: "snacks", selected: true ...
I have included javascript for dynamically adding input fields but the first time its clicked it doesn't style correctly. Here is how it looks before utilizing add button (ignore the Author 1/...
I have included javascript for dynamically adding input fields but the first time its clicked it doesn't style correctly. Here is how it looks before utilizing add button (ignore the Author 1/...