nuxt.js

I want to use window.localStorage in Vuex in Nuxt.js

主宰稳场 提交于 2020-01-29 03:16:49
问题 I developing nuxt.js app. And point is login & logout. We will develop a login to the JWT system. You must remain logged in at vuex. However, when I refresh the page, vuex is initialized. I've read git vuex-persistedstate , but it's hard to understand just how to initialize and set it. What is the best way to develop a login system in nuxt.js? Thanks. 回答1: Using vuex-persisted state would be the best use case for your scenario. I will walk you through the process of using vuex-persisted state

I want to use window.localStorage in Vuex in Nuxt.js

扶醉桌前 提交于 2020-01-29 03:16:38
问题 I developing nuxt.js app. And point is login & logout. We will develop a login to the JWT system. You must remain logged in at vuex. However, when I refresh the page, vuex is initialized. I've read git vuex-persistedstate , but it's hard to understand just how to initialize and set it. What is the best way to develop a login system in nuxt.js? Thanks. 回答1: Using vuex-persisted state would be the best use case for your scenario. I will walk you through the process of using vuex-persisted state

NuxtServerInit: Add Google-Tag-Manager scripts to head an body

泪湿孤枕 提交于 2020-01-24 19:44:09
问题 I use one nuxt instance to serve several domains with different languages. For each domain I use a different Google-Tag-Manager account. Within nuxtServerInit I add to the store the hostname and also the Google-Tag-Manager ID. Now I am looking for a way to add the Javascript snippets to my nuxt project. This one needs to be in the head <!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d

How can we maintain user logged in when access token expires and we need to login again to continue as normal user

孤者浪人 提交于 2020-01-24 19:33:07
问题 I'm using Nuxt-axios module with the proxy. For Error handling, I have common code in Plugins/axios.js export default function({ $axios, __isRetryRequest, store, app, redirect , payload , next}) { $axios.onRequest(config => { if (app.$cookies.get('at') && app.$cookies.get('rt') && config.url != '/post_login/') { config.headers.common['Authorization'] = `Bearer ${app.$cookies.get('at')}`; } }); $axios.onResponseError(err => { const code = parseInt(err.response && err.response.status) let

Nuxt JS Apollo data only available after page refresh

六眼飞鱼酱① 提交于 2020-01-23 12:25:11
问题 I am fetching some data using Apollo inside of Nuxt. Somehow, when navigating to that page I get an error of Cannot read property 'image' of undefined When I refresh the page, everything works as expected. I have a found a few threads of people having similar issues but no solution seems to work for me :/ This is my template file right now: /products/_slug.vue <template> <section class="container"> <div class="top"> <img :src="product.image.url"/> <h1>{{ product.name }}</h1> </div> </section>

duplicate namespace auth/ for the namespaced module auth

一笑奈何 提交于 2020-01-23 04:09:37
问题 I've been getting this error after installing nuxtjs module. I have tried every trick in the book to fix it, but seems like nothing is working.Added more information. [vuex] duplicate namespace auth/ for the namespaced module auth I've been frustrated with it. auth: { plugins: [{ src: '~/plugins/axios', ssr: true }, '~/plugins/auth.js'], vuex: { namespace: 'auth' }, strategies: { local: { endpoints: { login: { url: "login", method: "post", propertyName: "meta.token" }, user: { url: "me",

How do I change the URL of the page in Nuxt SSR mode without reloading the whole page?

蓝咒 提交于 2020-01-16 18:34:50
问题 I am trying to build a Master Detail View where list and detail are shown side by side on desktop but on different pages on mobile as shown in the image below I may have between 500 to 10000 items on the list to display I simulated both approaches with 10000 items, feel free to change the number in server/app.js file When I click on an item in the list, I want the URL to change so that I click back button I go to the previous button. The page should not reload for doing this and it should be

How to import CSS-Modules correctly with Nuxt?

北城以北 提交于 2020-01-16 17:24:29
问题 I'm using CSS Modules with Nuxt and have run into some issues when trying to import a stylesheet in my js. If I import my stylesheet directly into the... `<style module> @import './index.css'; </style>` ...everything works as expected. In my particular case I need to run a computed property to choose between two different stylesheets so instead of importing through the <style module> I need to import into <script> and implement the styles like so: <script> import foo from './index.css' export

I can't use third party components in Nuxt.js/vue.js

微笑、不失礼 提交于 2020-01-13 05:55:30
问题 I attempt use this library for my Nuxt project: getting-started I tried do how to written in docs, but in all variants get an error for exmaple: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. what i tried: <template> <div class="div-wrapper"> <h1>grge</h1> <div id="typeahead"><typeahead :data="USstate" placeholder="USA states"> </typeahead></div> </div> </template> <style lang="less"> .div-wrapper {

Managing State for Overlay Dismissed Components in Vuetify

自作多情 提交于 2020-01-13 03:39:14
问题 I'm building out a vuetify/nuxt frontend for the first time, and I've moved my v-navigation-drawer component out of the default.vue layout, and into it's own component, so that it can be reused in multiple layouts. The activator for this drawer still remains in the default.vue component, so I added a sidebar state to vuex: export const state = () => ({ baseurl: 'http://example.com/api/', sidebar: false, authenticated: false, token: null, user: null, }) The mutator for the sidebar looks like