Nuxt.js provides two ways to publish and deploy applications: server-side rendering application deployment and static application deployment
I chose the second. Executing the npm run generate
command can be packaged smoothly, but there is a problem
// nuxt.config.js
const axios = require("axios")
module.exports = {
generate: {
routes: function () {
return axios.get("https://my-api/users")
.then((res) => {
return res.data.map((user) => {
return "/users/" + user.id
})
})
}
}
}
unfortunately, I tried, but failed. Now that the project is online, I have changed the code and am forced to use / users?id=1
this way, but it looks very uncomfortable. This is not my original intention. If anyone has encountered this problem, I hope to communicate with me here