简体   繁体   English

Nuxt,Axios和Feathers中的登录系统

[英]Signin Login System in Nuxt, Axios and Feathers

I created a system of login and signup in nuxt, and the system get the database data, i create one 'for' and 'if' to verify if have someone logged, and i have a code to redirect to logged page if the conditional be true, but this dosn't worked like i thinked. 我在nuxt中创建了一个登录和注册系统,该系统获取了数据库数据,我创建了一个“ for”和“ if”来验证是否有人登录,并且如果有条件的话我有一个重定向到登录页面的代码是的,但这并没有像我想的那样起作用。

<script>
 import Logo from '~components/Logo.vue'
 import axios from 'axios'
 export default {
  components: {
   Logo
  },
  data () {
   return { test: [] }
  },
  mounted () {
   axios.get('http://localhost:3030/users').then((res) => { this.test = 
   res.data.data })
   for (let y of this.test) { if (y.loged) { location.href = 
  'http://localhost:3000/home' } }
     }
   }
</script>

我不知道为什么,但是我已经解决了我的问题,这是答案<script> import Logo from '~components/Logo.vue' import axios from 'axios' export default { components: { Logo }, data () { return { test: [], x: true } }, async mounted () { await axios.get('http://localhost:3030/users').then((res) => { this.test = res.data.data }) for (let y of this.test) { if (y.loged) { location.href = 'http://localhost:3000/home' } else { this.x = false } } } } </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM