【发布时间】:2018-12-31 03:42:32
【问题描述】:
我正在尝试使用 npm run generate 生成我的应用程序 在终端上。我没有收到任何错误,一切都很好。在我的开发服务器中,路由组件等一切正常,但是当我在 dist 文件夹中打开 index.html 时生成后,我无法访问其他页面,chrome 控制台上出现类似的错误。
Failed to load resource: net::ERR_FILE_NOT_FOUND
f8ff67c7350097487a5e.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
e63cddd635f290d15a6f.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
9a1a3c7742fdcce5403a.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
1e056384fb18617ca6a5.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
bde8656.png:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
我尝试将 dist 文件夹上传到我的 ftp 中,但是太相同了……
这是我的 nuxt.config 文件
const pkg = require('./package')
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://github.com/nuxt-community/axios-module#usage
'@nuxtjs/axios',
// Doc:https://github.com/nuxt-community/modules/tree/master/packages/bulma
'@nuxtjs/bulma',
// ['nuxt-validate', {
// lang: 'tr',
// // regular vee-validate options
// }]
],
/*
** Axios module configuration
*/
axios: {
// See https://github.com/nuxt-community/axios-module#options
},
/*
** Build configuration
*/
build: {
postcss: {
preset: {
features: {
customProperties: false
}
}
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}
【问题讨论】:
-
您的项目是否从服务器加载数据?
-
没有。只有一个 api 调用,我用响应来做一些事情。
-
如何打开生成的项目?如果您直接在浏览器中打开您的 html 文件,它将无法正常工作。你需要一个http服务器
-
@Aldarund 我已将 dist 文件夹的内容上传到我的 ftp 并且无法正常工作,我认为问题是浏览器在根目录之外搜索 _nuxt 文件夹
-
您是否通过根域(例如 yourdomain.com)上传和访问它?或 yourdomain.com/somedir ?