This file contains hidden or 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
... | |
{ rel: 'stylesheet', type: 'text/css', href: 'http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css' } | |
... |
This file contains hidden or 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 class="mt-5"> | |
<div class="container"> | |
<div class="row justify-content-md-center"> | |
<div class="col-8"> | |
<img :src="article.urlToImage" alt="Card image cap" class="img-fluid"> | |
<p class="card-text"><small class="text-muted">{{ article.publishedAt }} - {{ article.author }} - {{ article.source.name }}</small></p> | |
<h5 class="card-title">{{ article.title }}</h5> | |
<p class="card-text">{{ article.description }}</p> | |
</div> |
This file contains hidden or 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
... | |
methods : { | |
... | |
}, | |
openDetail (data) { | |
this.$store.commit('setArticle', data) | |
this.$router.replace({ 'path': '/detail' }) | |
} | |
}, | |
... |
This file contains hidden or 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
<div class="card" v-for="item in posts" v-bind:key="item.key"> |
This file contains hidden or 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
<div class="card" v-for="item in posts" v-bind:key="item.key" @click="openDetail(item)"> |
This file contains hidden or 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
import Vuex from 'vuex' | |
const createStore = () => { | |
return new Vuex.Store({ | |
state: { | |
article: {} | |
}, | |
mutations: { | |
setArticle (state, data) { | |
state.article = data |
This file contains hidden or 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
... | |
export default { | |
methods : { | |
loadMore () { | |
this.posts = [] | |
this.current += 9 | |
this.allPost.map((item, key) => item.description !== null && this.posts.length < this.current ? this.posts.push(item) : '') | |
} | |
}, | |
... |
This file contains hidden or 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
... | |
export default { | |
data () { | |
return { | |
allPost: [], | |
posts: [], | |
current: 9 | |
} | |
}, | |
... |
This file contains hidden or 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
// Add button "load more" before closing tag </template> | |
<button class="btn btn-primary btn-more" @click="loadMore">Load More</button> | |
</div> | |
</template> | |
// Add style for button "load more" after tag <style> | |
<style lang="scss" scoped> | |
.btn-more { |