Option 1
Use this.$parent.limitByNumberfrom a child component. So your component template will be this way
<template>
<div class="Post" v-for="post in list | limitBy this.$parent.limitByNumber">
</div>
</template>
Option 2
If you want to use props, you can also achieve what you want. Like this.
Parent
<template>
<post :limit="limitByNumber"></post>
</template>
<script>
export default {
data () {
return {
limitByNumber: 4
}
}
}
</script>
Baby pots
<template>
<div class="Post" v-for="post in list | limitBy limit">
....
</div>
</template>
<script>
export default {
props: ['list', 'limit'],
created() {
this.list = JSON.parse(this.list);
}
}
</script>
source
share