nuxt.js

Run function AFTER route fully rendered in Nuxt.js

↘锁芯ラ 提交于 2021-01-27 08:15:27
问题 Background: I'm building an SSR website using Nuxt. I want to run a script to fix some typography issues (orphaned text in headers). I can't do this UNTIL AFTER the DOM is rendered. How can I implement this function once so it runs after each page's DOM is rendered? It can be either in the Router or in a Nuxt Layout, or elsewhere. What I've tried: In my layout.vue , Mounted() only runs on the first load (as expected) and adding $nextTick doesn't seem to affect that. This is even true for

Run function AFTER route fully rendered in Nuxt.js

别说谁变了你拦得住时间么 提交于 2021-01-27 08:15:25
问题 Background: I'm building an SSR website using Nuxt. I want to run a script to fix some typography issues (orphaned text in headers). I can't do this UNTIL AFTER the DOM is rendered. How can I implement this function once so it runs after each page's DOM is rendered? It can be either in the Router or in a Nuxt Layout, or elsewhere. What I've tried: In my layout.vue , Mounted() only runs on the first load (as expected) and adding $nextTick doesn't seem to affect that. This is even true for

nuxtjs cannot display dynamic url on production

假如想象 提交于 2021-01-27 05:30:23
问题 I'm using nuxjs to build my project and I create a page which displays place information dynamically. when I run npm run dev and test on http://localhost:3000/place/66bb50b7a5 is work well. but after I run npm run generate , I get the dist folder, I put in on MAMAP and try to run http://mysite:7074/place/66bb50b7a5, it shows 404 page not found. My dist folder is like this please tell me what wrong on my code and what I should do. Thank you. 回答1: You have to config your web server to response

nuxtjs cannot display dynamic url on production

淺唱寂寞╮ 提交于 2021-01-27 05:27:40
问题 I'm using nuxjs to build my project and I create a page which displays place information dynamically. when I run npm run dev and test on http://localhost:3000/place/66bb50b7a5 is work well. but after I run npm run generate , I get the dist folder, I put in on MAMAP and try to run http://mysite:7074/place/66bb50b7a5, it shows 404 page not found. My dist folder is like this please tell me what wrong on my code and what I should do. Thank you. 回答1: You have to config your web server to response

How can fetch data in NUXT.JS on DRF

瘦欲@ 提交于 2021-01-24 07:11:32
问题 I tried NUXT and tried following the manual on his website. But now I'm stuck with the problem of fetching data from DJANGO. this my code. <template> <div> <ul v-for="product in products" :key="product.results.id"> <NuxtLink :to="`/${product.results.id}`"> <li>{{ product.results.id }}</li> </NuxtLink> </ul> </div> </template> <script> export default { async asyncData() { const products = await fetch( '***/product_api/api/v1/Product/?format=json' ).then((res) => res.json()) // .then(productmap

How to set beforeResolve navigation guard in Nuxt.js

纵然是瞬间 提交于 2021-01-22 12:09:34
问题 Is there a way to add beforeResolve navigation guard in nuxt.config.js? My nuxt.config.js module.exports { ... router: { beforeResolve(to, from, next) { if (this.$store.getters.isLoggedIn) next('/resource') } } ... } But its never gets called! I've been trying to achieve a redirection before the component is mounted based on the users logged in state on the vuex store. 回答1: You have 2 options for this. You can set a global rule via the middleware or in the respective page. // middleware/route

How to set beforeResolve navigation guard in Nuxt.js

痴心易碎 提交于 2021-01-22 12:09:06
问题 Is there a way to add beforeResolve navigation guard in nuxt.config.js? My nuxt.config.js module.exports { ... router: { beforeResolve(to, from, next) { if (this.$store.getters.isLoggedIn) next('/resource') } } ... } But its never gets called! I've been trying to achieve a redirection before the component is mounted based on the users logged in state on the vuex store. 回答1: You have 2 options for this. You can set a global rule via the middleware or in the respective page. // middleware/route

How to deploy a finished nuxt.js app to a webserver?

橙三吉。 提交于 2021-01-22 05:38:26
问题 At work, I got some little insight to nuxtjs development and I got very interested in it. So, I started developing on my own a little bit, but now, I'm stuck with my finished project. To develop, I spin up a local server with "npm run dev" in my CLI. This all works fine. But, how do I deploy my now finished project to run it in something like nginx (or are there better alternatives that run on an Windows Server environment) on my home server? I heard about "npm run build" into my CLI, but how

How to watch prop even if it does not change?

可紊 提交于 2021-01-20 13:35:27
问题 I have watcher with the same name as a prop. The prop is dynamically set in a parent component on some event. I need something that triggers some function in the child component with property value every time the event is triggered on parent -even if the prop it set is the same. Is there any watcher option or other method of handling such case which would allow me to do that ? What I tried (this is in Post component): watch: { replyClicked: { handler(newVal, oldVal) { console.log(newVal,

Is there something to auto update this code in vue?

夙愿已清 提交于 2021-01-20 13:35:15
问题 I got this button in the navigator that shows up when a user is logged in and when the user logs out the button is gone. But now i need to refresh my page before the button removes/appears. Here is my code: Button: <div v-if="ingelogd"> <div class="w-2/12 hidden lg:flex" v-for="(data, index) in allIngelogds" :key="index"> <button @click="uitloggen" class="downloadbtn"> {{ data.uitloggenKnop }} </button> </div> </div> in data:() i return this: ingelogd: false and then i created a mounted()