I'm trying to build a quick prototype of a simple interactive story with Vue.js (example of what I'm trying to achieve : https://www.getbadnews.com/#play) but I can't get my Vue app to display elements from an array one by one in a list inside an unordered list when I click a button.
Any idea as to the best way to achieve this?
Here is my current code:
const InteractiveStory = {
data() {
return {
list: [];
}
},
methods: {
addList: function() {
var number = 0;
var storySnippets = ["Hello", "Two", "Three", "Four"];
this.list.push(storySnippets[number]);
number++;
},
},
}
Vue.createApp(InteractiveStory).mount('#story')
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="story">
<ul>
<li v-for="item in list"></li>
</ul>
<button @click="addList()">Next</button>
</div>
Thanks for your help, I've been stuck on this for two days :)