Created
April 10, 2020 19:20
-
-
Save jensen/d133c04194449b52291a0dc8bfeef151 to your computer and use it in GitHub Desktop.
Example of data loading in an ordered table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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