Last active
May 26, 2020 20:36
-
-
Save szabomikierno/99d81bd7a9314898bb29e052e6c16dc9 to your computer and use it in GitHub Desktop.
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="container"> | |
| <example-article v-for="article in articles" :article="article"></example-article> | |
| <button @click="fixArticles()">Fix Articles</button> | |
| <button @click="pushArticle({title: 'Third Title', content: 'Content of the third article'})">Push Article</button> | |
| </div> | |
| </template> | |
| <script> | |
| let ExampleArticle = { | |
| props: ['article'], | |
| template: `<div class='row'> | |
| <h5>{{article.title}}</h5> | |
| <p>{{article.content}}</p> | |
| </div>` | |
| } | |
| export default { | |
| components: { | |
| 'example-article': ExampleArticle | |
| }, | |
| data () { | |
| return { | |
| articles: [{ | |
| title: "First Title", | |
| content: "Content of the first alticle" | |
| }, { | |
| title: "Second Title", | |
| content: "Content of the second alticle" | |
| }], | |
| } | |
| }, | |
| methods: { | |
| fixArticles() { | |
| for (var i = this.articles.length - 1; i >= 0; i--) { | |
| this.articles[i].content = this.articles[i].content.replace("alticle", "article") | |
| } | |
| }, | |
| pushArticle(article) { | |
| this.articles[this.articles.length] = article | |
| } | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment