added axios, datarest, vuex

This commit is contained in:
2019-04-02 12:59:58 +02:00
parent 1017ecdc95
commit 8dd21b9e2d
11 changed files with 177 additions and 21 deletions
+46
View File
@@ -0,0 +1,46 @@
<template>
<section v-if="opened != null">
<h2>{{ opened.title }}</h2>
<p>{{ opened.body }}</p>
<span
@click="closePost()"
>
close</span>
</section>
<ul v-else>
<li
v-for="post in posts"
:key="post.id"
>
<h2>
<a
@click="openPost(post)"
>
{{ post.title }}</a></h2>
</li>
</ul>
</template>
<script>
// import store from './store'
// import datarest from 'components/data/datarest'
import { mapState, mapActions } from 'vuex'
// import { mapState } from 'vuex'
export default {
computed: mapState({
opened: state => state.posts.opened,
posts: state => state.posts.all
}),
methods: mapActions('posts', [
'openPost',
'closePost'
]),
created () {
this.$store.dispatch('posts/getAllPosts')
}
}
</script>
@@ -1,5 +0,0 @@
<template>
<section>
<p>Post hoc impie perpetratum quod in aliis quoque iam timebatur, tamquam licentia crudelitati indulta per suspicionum nebulas aestimati quidam noxii damnabantur. quorum pars necati, alii puniti bonorum multatione actique laribus suis extorres nullo sibi relicto praeter querelas et lacrimas, stipe conlaticia victitabant, et civili iustoque imperio ad voluntatem converso cruentam, claudebantur opulentae domus et clarae.</p>
</section>
</template>