parsley/app/javascript/components/TheRecipeList.vue

51 lines
800 B
Vue
Raw Normal View History

2018-03-29 01:57:00 -05:00
<template>
<div>
2018-03-30 14:31:09 -05:00
<h1 class="title">Recipes</h1>
<button type="button" class="button">Create Recipe</button>
<table class="table">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr v-for="r in recipes" :key="r.id">
<td>{{r.name}}</td>
</tr>
</tbody>
</table>
2018-03-29 01:57:00 -05:00
</div>
</template>
<script>
2018-03-30 14:31:09 -05:00
import api from "../lib/Api";
2018-03-29 01:57:00 -05:00
export default {
2018-03-30 14:31:09 -05:00
data() {
return {
recipeData: null
};
},
created() {
this.loadResource(api.getRecipeList(), data => this.recipeData = data);
},
2018-03-29 01:57:00 -05:00
2018-03-30 14:31:09 -05:00
computed: {
recipes() {
if (this.recipeData) {
return this.recipeData.recipes;
} else {
return [];
}
}
}
2018-03-29 01:57:00 -05:00
}
</script>