error type check failed for prop "news" when using Nuxt.js. Expected Array, got Function. Found in .
but there is no problem with re-npm run dev, but this error is reported every time the browser is changed a little. But the terminal is normal.
<template>
<div class="leo-news">
<div class="icon"/>
<div class="news-list">
<p
v-for="(item, index) in news"
:key="index"><a>{{ item.title }}</a>
</div>
</div>
</template>
<script>
export default {
props: {
news: {
type: Array,
default: () => Array
}
},
data() {
return {}
},
created() {}
}
</script>
page
<style lang="scss">
.leo-news {
height: 2rem;
background: -sharpfff;
padding-left: 0.5rem;
padding-right: 0.5rem;
.icon {
width: 1.2rem;
height: 1.5rem;
background: blue;
float: left;
}
.news-list {
width: 10rem;
font-size: 0.4rem;
float: left;
padding-left: 0.333333rem;
p {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
p:nth-child(2) {
margin-top: 0.4rem;
}
}
}
</style>
<template>
<div class="content">
<section>
<m-banner/>
<m-LeoNews :news="news"/>
</section>
<section class="container">
<m-vedio/>
</section>
<section class="container">
<m-huoke/>
</section>
</div>
</template>
<script>
import axios from "~/fetch/fetch.js"
import Banner from "~/components/banner.vue"
import VedioCase from "~/components/vedioCase.vue"
import LeoNews from "~/components/leoNews.vue"
import Huoke from "~/components/huoke/huoke.vue"
export default {
components: {
"m-banner": Banner,
"m-vedio": VedioCase,
"m-LeoNews": LeoNews,
"m-huoke": Huoke
},
data() {
return {
news: []
}
},
created() {},
asyncData({ params }) {
//
//
return axios.getNews({ limit: 2 }).then(res => {
return { news: res.data }
})
}
}
</script>
<style lang="scss">
</style>