Skip to content

Instantly share code, notes, and snippets.

@jensen
Created April 10, 2020 19:20
Show Gist options
  • Save jensen/d133c04194449b52291a0dc8bfeef151 to your computer and use it in GitHub Desktop.
Save jensen/d133c04194449b52291a0dc8bfeef151 to your computer and use it in GitHub Desktop.
Example of data loading in an ordered table
<template>
<div>
<md-table v-model="players" :table-header-color="tableHeaderColor">
<md-table-row slot="md-table-row" slot-scope="{ item }">
<md-table-cell md-label="Name">{{ item.player }}</md-table-cell>
<md-table-cell md-label="Completed">{{
item.mCompleted
}}</md-table-cell>
<md-table-cell md-label="Records">{{ item.mRecords }}</md-table-cell>
<md-table-cell md-label="Points">{{ item.points }}</md-table-cell>
</md-table-row>
</md-table>
<div v-if="loading" class="loading">
Loading...
</div>
</div>
</template>
<script>
import axios from "axios";
axios.defaults.baseURL = "http://localhost:3000";
export default {
name: "ordered-table",
props: {
tableHeaderColor: {
type: String,
default: ""
}
},
data() {
return {
loading: false,
selected: [],
players: []
};
},
created() {
this.fetchData();
},
methods: {
fetchData() {
this.loading = true;
axios
.get("/players")
.then(response => {
this.players = response.data;
this.loading = false;
})
.catch(error => console.log(error));
}
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment