1 <div id='lazyload' class='vux-1px-tb' @click='loadMoreData' v-show='islazyshow'> //在这个子组件里面loadMoreData自定义事件用于把信息传到父组件 2 <span>{{loadText}}</span> // islazyShow是父组件的数据变化传到子组件 3 </div> 4 </div> 5 </template>
6 <script> 7 import dateutil from '@/util/date'; 8 export default { 9 data() { 10 return { 11 12 } 13 }, 14 props: { 15 getCorpList: Array, 16 loadBtnText: String, 17 islazyshow:Boolean//组件内利用props传值 18 }, 19 created() { 20 console.log('coprlistgroup', this.$route.path) 21 }, 22 computed: { 23 corpList() { 24 return JSON.parse(JSON.stringify(this.getCorpList)) 子组件中 25 },
1 <kp-corp-group :getCorpList="corpList" :loadBtnText="setLoadText" :islazyshow="islazyshow" @corpDetail="getCorpDetail" @loadMore="loadMoreData" ></kp-corp-group>
data () { return { islazyshow:false,//然后你可以用了(父组件的文件中) isLoadMore: true, corpList: [] } callback: res => { console.log('获取企业列表成功') this.$store.commit('mergeAllCorpList', { items: res.data }) this.loading = false this.corpList = this.corpList.concat(res.data) if (this.corpList.length < 10) { this.islazyshow = false } else if(this.corpList.length >= 10 && this.corpList.length != res.total){ this.islazyshow = true this.setLoadText = '点击加载更多数据' } else if(this.corpList.length === res.total){ this.islazyshow = true this.isLoadMore = false this.setLoadText = '暂无更多数据' } this.chooseSource = this.chooseStatus = false } } corpList(request) } },
年轻的时候无论你去那家公司记得一件事,成长比对错重要。
https://www.cnblogs.com/ygtq-island/p/6864477.html 初学者看这个传值