nuxtでトップページをhttps://〜〜〜〜〜(ホスト名)/aaa/に表示したく、次のように設定したく、nuxt.config.jsを以下のように記述しました。
JavaScript
1const pkg = require('./package') 2 3const environment = process.env.NODE_ENV || 'development'; 4const envSet = require(`./env.${environment}.js`); 5Object.assign(envSet, require("./env.common.js")) 6 7module.exports = { 8 mode: 'universal', 9 10 env: envSet, 11 12 router: { 13 base: '/aaa/' 14 }, 15 16 /* 17 ** Headers of the page 18 */ 19 head: { 20 titleTemplate: '%s' + envSet.titleTemplate, 21 meta: [ 22 { charset: 'utf-8' }, 23 { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 24 { hid: 'description', name: 'description', content: pkg.description } 25 ], 26 link: [ 27 { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } 28 ] 29 }, 30 31 /* 32 ** Customize the progress-bar color 33 */ 34 loading: { color: '#fff' }, 35 36 /* 37 ** Global CSS 38 */ 39 css: [ 40 ], 41 42 /* 43 ** Plugins to load before mounting the App 44 */ 45 plugins: [ 46 ], 47 48 /* 49 ** Nuxt.js modules 50 */ 51 modules: [ 52 // Doc: https://github.com/nuxt-community/axios-module#usage 53 '@nuxtjs/axios' 54 ], 55 /* 56 ** Axios module configuration 57 */ 58 axios: { 59 // See https://github.com/nuxt-community/axios-module#options 60 }, 61 62 /* 63 ** Build configuration 64 */ 65 build: { 66 /* 67 ** You can extend webpack config here 68 */ 69 extend(config, ctx) { 70 } 71 } 72} 73
しかし、npm run devしてlocalhost:3000/aaa/にアクセスすると次のエラーが出ます。
baseを"/"にしてlocalhost:3000にアクセスするとpages/index.vueが開けます。
環境はnpx create-nuxt-appで作っています。
nuxt 2.0.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/05 05:19
2019/01/05 08:17