2017-07-01 6 views
0

ログインとサインアップのシステムをnuxtで作成しました。システムはデータベースのデータを取得し、誰かがログに記録されているかどうかを確認するために '条件付きであればログに記録されたページにリダイレクトするコードがありますが、これは私が思ったようにうまく機能しませんでした。Nuxt、Axios、Feathersのサインインログインシステム

<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> 

答えて

0

私はなぜ知らないが、私は私の問題の解決を得、これは答え <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>

です