小编Ang*_*gel的帖子

如何在vue 3合成API中显示加载gif

我对 vue 很陌生。我想做的是在等待端点返回时加载 gif。

我正在尝试使用 watchEffect,但我无法弄清楚。如果这是正确的方法我该怎么做?如果不是我应该用什么代替?

谢谢

编辑:代码

<template>
    <div class="player-list" :key="playerList.id" v-for="playerList in players.playerLists">
        <PlayerList :playerList="playerList" />
    </div>
</template>

<script>
import getPlayers from "@/composables/getPlayers";
import PlayerList from "@/components/PlayerList";
import { watchEffect } from 'vue';

export default {
    name: 'PlayerLists',
    components: {
        PlayerList
    },
    setup() {

        const { players, error, load } = getPlayers() //request endpoint
        load()

        watchEffect(() => {
            console.log('watch effect function')
        })

        return { players, error }
    }
}
</script>
Run Code Online (Sandbox Code Playgroud)

vue.js vue-composition-api

2
推荐指数
1
解决办法
4968
查看次数

标签 统计

vue-composition-api ×1

vue.js ×1