nuxt

Nuxt How to set baseURL in dev or production

别等时光非礼了梦想. 提交于 2019-12-08 04:05:36
问题 This seems like a simple Nuxt question, but I just can't figure it out. When running "NPM run dev" I want to set the Axios baseURL to "localhost/api" and when running from the dist folder after "NPM run generate" I want the baseURL to be "/api". Is there a simple solution? 回答1: This is the way to do it: let development = process.env.NODE_ENV !== 'production' module.exports = { axios: { baseURL: development ? 'http://localhost:3001/api' : 'https://domain/api' }, modules: [ '@nuxtjs/axios' ], }

Data() VS asyncData() in Nuxt & vue

本小妞迷上赌 提交于 2019-12-06 04:04:40
问题 both data() and async data() gives the same result (and it is obvious that the results from asyncData() override the results from data() ) and both results in HTML code in the source code (i.e the code rendered in the server side) also both can be used to " await " the data to be fetched (ex: using axios) so, what is the difference between them? <template> <div> <div>test: {{test}}</div> <div>test2: {{test2}}</div> <div>test2: {{test3}}</div> <div>test2: {{test4}}</div> </div> </template>

How to run NUXT (npm run dev) with HTTPS in localhost?

﹥>﹥吖頭↗ 提交于 2019-12-01 06:29:40
问题 EDIT: Updated the text in general to keep it shorter and more concise. I am trying to configure HTTPS when I run npm run dev so I can test MediaStream and alike locally (for which browsers require me to provide HTTPS). I am trying to configure it through nuxt.config.js but without any success. Here is my nuxt.config.js file: import fs from "fs"; import pkg from "./package"; export default { mode: "spa", /* ** Headers of the page */ head: { title: pkg.name, meta: [ { charset: "utf-8" }, { name

Dynamically get image paths in folder with Nuxt

别说谁变了你拦得住时间么 提交于 2019-11-30 20:20:23
I'm using nuxt with vuetify. I have a working carousel component .I want to generate a list of The .png files in the static folder. Following Dynamically import images from a directory using webpack and Following https://webpack.js.org/guides/dependency-management/#context-module-api my component looks like: <template> <v-carousel> <v-carousel-item v-for="(item,i) in items" :key="i" :src="item.src"></v-carousel-item> </v-carousel> </template> <script> var cache = {}; function importAll(r) { r.keys().forEach(key => cache[key] = r(key)); } var getImagePaths = importAll(require.context('../static

Dynamically get image paths in folder with Nuxt

半世苍凉 提交于 2019-11-30 03:51:29
问题 I'm using nuxt with vuetify. I have a working carousel component .I want to generate a list of The .png files in the static folder. Following Dynamically import images from a directory using webpack and Following https://webpack.js.org/guides/dependency-management/#context-module-api my component looks like: <template> <v-carousel> <v-carousel-item v-for="(item,i) in items" :key="i" :src="item.src"></v-carousel-item> </v-carousel> </template> <script> var cache = {}; function importAll(r) { r