vue-component

Only show associated data in v-for

对着背影说爱祢 提交于 2020-11-29 11:10:20
问题 I have the following code: <template> <div> <div v-for="title in titles"> <h1>{{ title }}</h1> <a @click="showSub">Click Here</a> <div v-if="subshown"> Shown </div> </div> </div> </template> <script> export default { data() { return { subshown: false, titles: [] } }, methods: { showSub: function () { this.subshown = true; // do something more } } } </script> When i now click on the Click Here Button, the associated subshown from the current title should be shown. At the moment, when i click

Only show associated data in v-for

筅森魡賤 提交于 2020-11-29 11:06:09
问题 I have the following code: <template> <div> <div v-for="title in titles"> <h1>{{ title }}</h1> <a @click="showSub">Click Here</a> <div v-if="subshown"> Shown </div> </div> </div> </template> <script> export default { data() { return { subshown: false, titles: [] } }, methods: { showSub: function () { this.subshown = true; // do something more } } } </script> When i now click on the Click Here Button, the associated subshown from the current title should be shown. At the moment, when i click

Creating local copy of passed props in child component in vue.js?

依然范特西╮ 提交于 2020-11-26 08:11:43
问题 In vue.js what is the right way to edit prop without changing parent data? What I mean by that is whenever we pass any property from parent to child in vue.js then if we make any change to that property in child component then the change is also reflected in parent's component. Is there any way in vue.js to make a local copy of passed property in a child? I googled this but everywhere it is written that we can achieve this by doing this. props:["user"], data(){ return { localUser: Object

Vue.js- Vuex updating an object within an array inside state not reflected in component DOM

给你一囗甜甜゛ 提交于 2020-11-25 03:27:09
问题 Vuex/store : import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); const store = new Vuex.Store({ state: { todos: [ {id: 1, text: 'Clean kitchen', done: false}, {id: 2, text: 'Clean bedroom', done: false}, {id: 3, text: 'Clean bathroom', done: false}, {id: 3, text: 'Clean clothes', done: true}, ], }, mutations: { x(state, data) { state.todos[0] = data; } }, }); export default store; Test.vue : <template> <div class="container"> <ul> <li v-for="(item, i) in todos" :key="i" > <span