Vue.component('blog-post',{
props:['post'],// props: ['title'],
template:`
<div class="blog-post">
<h3>{{ post.title }}</h3>
<button v-on:click="$emit('enlarge-text', 0.1)">
Enlarge text
</button>
<div v-html="post.content"></div>
</div>
`})newVue({
el:'#blog-post-demo',
data:{
posts:[],
postFontSize:1},
created:function(){// Alias the component instance as `vm`, so that we // can access it inside the promise functionvar vm =this// Fetch our array of posts from an APIfetch('https://jsonplaceholder.typicode.com/posts').then(function(response){return response.json()}).then(function(data){
vm.posts = data
})},
methods:{
onEnlargeText:function(enlargeAmount){this.postFontSize += enlargeAmount
}}})