小编Chr*_*s X的帖子

从 Vue.js 中的 API 获取 HTML

所以,我有一个 API 需要从中检索数据。我正在使用 vue.js 和 axios。我有一个 app.vue 文件,其中导入了一个名为 Contests 的组件,在竞赛中我进行 api 调用,我能够检索任何数据,但它是 HTML,当我将其放入最终的组件中时屏幕上只显示 HTML,有人有什么想法吗?这是我的代码应用程序组件

<template>
    <div>
        <app-contests> </app-contests>
    </div>
</template>

<script>
    import Contests from './components/Contests.vue';

    export default {
        components: {
            appContests: Contests
        }
    }
</script>

<style>

</style>
Run Code Online (Sandbox Code Playgroud)

我在哪里进行 api 调用

<template>
    <div>
        <div class="container">
            {{info}} 
        </div>
        <div v-if="errored">
            <h1>We're sorry, we cannot retrieve this information at the moment. Please come back later.</h1>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                info: null
            }
        },
        mounted() {
            axios …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

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

标签 统计

javascript ×1

vue.js ×1