Trying to create a small application to show some news, but can't figure this error out. What am I doing wrong?
I'am trying to show the news one at a time by visually "sliding" through the news. The application runs and work, but still shows this error:
[Vue warn]: Error in created hook: "TypeError: handler.call is not a function"
Template:
<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>
Script:
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)
}
}
}
You wrote mounted() in the right way, but the created function definition is wrong. 1st brackets missing.
created: {
}
//change it to
created() {
}
please change
created() {
...
}
OR
created=() =>{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With