Skip to content

Instantly share code, notes, and snippets.

@Konafets
Last active July 23, 2019 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Konafets/3e5f94af8d9c737e104b90c2f08c4be9 to your computer and use it in GitHub Desktop.
Save Konafets/3e5f94af8d9c737e104b90c2f08c4be9 to your computer and use it in GitHub Desktop.
Watching child component computed properties
<template>
<table-component
:data="[
{ firstName: 'John', birthday: '04/10/1940'},
{ firstName: 'Paul', birthday: '18/06/1942'},
{ firstName: 'George', birthday: '25/02/1943'},
{ firstName: 'Ringo', birthday: '07/07/1940'},
]"
sort-by="firstName"
sort-order="asc"
ref="table"
>
<table-column show="firstName" label="First name"></table-column>
<table-column show="birthday" label="Birthday" :filterable="false" data-type="date:DD/MM/YYYY"></table-column>
<template slot="tfoot">
<th>&nbsp;</th>
<th>Total: {{ sum }}</th>
</template>
</table-component>
</template>
<script>
// some code
data() {
return {
sum: 0,
}
},
mounted() {
this.$watch(() => this.$refs.table.displayedRows.length, (value) => { this.sum = value;})
},
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment