64 lines
1.0 KiB
Vue
64 lines
1.0 KiB
Vue
<template>
|
|
<div class="fruits">
|
|
<h2>Directory</h2>
|
|
<Grid v-if="!error" :data="this.fruits" />
|
|
<div class="alert" v-else>
|
|
{{ error }}
|
|
<pre><span>$</span> yarn run api</pre>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState } from "vuex";
|
|
import Grid from "@/components/Grid";
|
|
|
|
export default {
|
|
name: "Fruits",
|
|
components: { Grid },
|
|
computed: {
|
|
...mapState(["fruits"])
|
|
},
|
|
data() {
|
|
return {
|
|
error: null
|
|
};
|
|
},
|
|
async created() {
|
|
await this.$store.dispatch("getFruits").catch(err => (this.error = err));
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.fruits {
|
|
margin: 0 auto;
|
|
max-width: 1200px;
|
|
}
|
|
|
|
.alert {
|
|
box-sizing: border-box;
|
|
margin: 0 auto;
|
|
width: 80%;
|
|
background-color: #d63031;
|
|
color: @color-2;
|
|
padding: 1rem 1.5rem;
|
|
border-radius: 4px;
|
|
|
|
@media screen and (min-width: @sm) {
|
|
width: 50%;
|
|
max-width: 535px;
|
|
}
|
|
|
|
pre {
|
|
padding: 1rem;
|
|
border-radius: 4px;
|
|
background-color: rgb(45, 48, 55);
|
|
|
|
span {
|
|
color: @color-3;
|
|
}
|
|
}
|
|
}
|
|
</style>
|