Laravel 和 Vue - handler.call 不是函数

Mar*_*ann 9 php laravel vue.js

试图创建一个小应用程序来显示一些新闻,但无法弄清楚这个错误。我究竟做错了什么?

我试图通过视觉“滑动”新闻来一次显示一个新闻。应用程序运行并工作,但仍显示此错误:

[Vue warn]: Error in created hook: "TypeError: handler.call is not a function"
Run Code Online (Sandbox Code Playgroud)

模板:

<template>
    <div>
        <div class="a_news" v-for="aNews in news">
        <span v-show="true">
            <h1 class="title" v-text="aNews.title"></h1>
            <div class="text" v-text="aNews.text"></div>
            <div class="aNews_image"><img v-bind:src="aNews.images[0]"/></div>
        </span>
        </div>
    </div>
</template>
Run Code Online (Sandbox Code Playgroud)

脚本:

export default {
        data() {
            return {
                news: [],
            }
        },
        computed: {

        },
        created: {

        },
        mounted() {
            this.getData(false, 0);
        },
        methods: {
            getData(oldnum, num) {

                const CORS_PROXY = "https://cors-anywhere.herokuapp.com/";
                axios.get(CORS_PROXY + 'URL').then(resp => {
                    console.log(resp.data);
                    this.news.push(resp.data.slides[num]);
                });
                setTimeout(function () {
                    if(oldnum == false) {
                        oldnum = num;
                    }
                    if(oldnum >= 0) {
                        oldnum = num;
                        num = num +1
                    }
                    this.news = [];
                    if(num >= 8) {
                        this.getData(false,0)
                    }else{
                        this.getData(oldnum,num)
                    }

                }.bind(this), 25000)
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

小智 9

您以正确的方式编写了mounted(),但是创建的函数定义是错误的。缺少第一个括号。

 created: {

    }

 //change it to

 created() {

    }
Run Code Online (Sandbox Code Playgroud)