nuxt.js

How to add headers on Nuxt static files response?

社会主义新天地 提交于 2020-03-03 06:05:00
问题 I have a json file on static folder and I'm trying to access it from another web site, but I'm having problem with the CORS. How can I add headers (like Access-Control-Allow-Origin) on the static files response? I tried this https://github.com/nuxt/nuxt.js/issues/2554#issuecomment-363795301, but didn't work for static files. module.exports = function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Headers', '*'); res.setHeader('Access

How to add headers on Nuxt static files response?

孤人 提交于 2020-03-03 06:04:27
问题 I have a json file on static folder and I'm trying to access it from another web site, but I'm having problem with the CORS. How can I add headers (like Access-Control-Allow-Origin) on the static files response? I tried this https://github.com/nuxt/nuxt.js/issues/2554#issuecomment-363795301, but didn't work for static files. module.exports = function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Headers', '*'); res.setHeader('Access

How to get current route name in Nuxt.js?

自作多情 提交于 2020-02-27 04:38:47
问题 I'm using Nuxt.js for building a static website. How to access in component's script code currently displayed route name (I would like to avoid reading direct url from browser location)? Can I somehow access $route.name ? 回答1: yes you can use vuejs route objects like $route.name or $route.path $nuxt.$route.path return current path $nuxt.$route.name The name of the current route, if it has one. Route Object Properties A route object represents the state of the current active route. It contains

How to get current route name in Nuxt.js?

断了今生、忘了曾经 提交于 2020-02-27 04:36:16
问题 I'm using Nuxt.js for building a static website. How to access in component's script code currently displayed route name (I would like to avoid reading direct url from browser location)? Can I somehow access $route.name ? 回答1: yes you can use vuejs route objects like $route.name or $route.path $nuxt.$route.path return current path $nuxt.$route.name The name of the current route, if it has one. Route Object Properties A route object represents the state of the current active route. It contains

Import UI library modularized in nuxtjs

谁说胖子不能爱 提交于 2020-02-25 08:31:40
问题 I'm learning nuxtjs and i use ant-design-vue as my ui library, i'm able to import the library as a plugin and it works fine import Vue from 'vue' import Antd from 'ant-design-vue'; export default () => { Vue.use(Antd) } but this import the components globally, but what i wanted to do is to import individual components into specific pages not globally since nuxt will auto lazy load this, ps: i can import individual components using the plugin and it works but it's still global import. for

Import UI library modularized in nuxtjs

北慕城南 提交于 2020-02-25 08:31:30
问题 I'm learning nuxtjs and i use ant-design-vue as my ui library, i'm able to import the library as a plugin and it works fine import Vue from 'vue' import Antd from 'ant-design-vue'; export default () => { Vue.use(Antd) } but this import the components globally, but what i wanted to do is to import individual components into specific pages not globally since nuxt will auto lazy load this, ps: i can import individual components using the plugin and it works but it's still global import. for

Import UI library modularized in nuxtjs

不想你离开。 提交于 2020-02-25 08:31:09
问题 I'm learning nuxtjs and i use ant-design-vue as my ui library, i'm able to import the library as a plugin and it works fine import Vue from 'vue' import Antd from 'ant-design-vue'; export default () => { Vue.use(Antd) } but this import the components globally, but what i wanted to do is to import individual components into specific pages not globally since nuxt will auto lazy load this, ps: i can import individual components using the plugin and it works but it's still global import. for

How to check my create-nuxt-app version and upgrade it?

£可爱£侵袭症+ 提交于 2020-02-25 06:08:40
问题 Background: Previously, running yarn create nuxt-app myApp installs Nuxt v2.4.0 but today for example I noticed you downgraded to Nuxt v2.0.0. I did not change the development environment so I can not understand this behavior. I did some search and complained elsewhere when I landed on this: So the OP was asked to upgrade his create-nuxt-app version. Question : But how to do that ? How to check which create-nuxt-app I do have ? Bonus: I read why does Create-Nuxt-App installs nuxt version 1.4

How to check my create-nuxt-app version and upgrade it?

百般思念 提交于 2020-02-25 06:06:20
问题 Background: Previously, running yarn create nuxt-app myApp installs Nuxt v2.4.0 but today for example I noticed you downgraded to Nuxt v2.0.0. I did not change the development environment so I can not understand this behavior. I did some search and complained elsewhere when I landed on this: So the OP was asked to upgrade his create-nuxt-app version. Question : But how to do that ? How to check which create-nuxt-app I do have ? Bonus: I read why does Create-Nuxt-App installs nuxt version 1.4

How to use workbox-webpack-plugin together with Nuxt PWA

那年仲夏 提交于 2020-02-25 04:09:26
问题 I'm currently on Nuxt with PWA Plugin, including workbox module. However if I'm not mistaken this plugin doesn't allow to add the assets generated by webpack to precaching. Is it possible to use workbox-webpack-plugin for only generating the precaching part of the sw.js file? If so, how would it be done? There is some documentation on https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin, however I'm not sure how to apply this to the Nuxt PWA context. 回答1: Turns out