第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

關(guān)于list組件點擊到info組件詳情中報錯 state is not defined,如果刪去store.commit(),不報錯但又顯示全部列表內(nèi)容

List.vue

<template>

<div>

?<ul>

? <li v-for="(item, index) in pageLists"

? ?:key = "index"

? ?@click="more(index)"

>

? ? {{index}} - {{ item.title }} - {{ item.content }}

? ?</li>

? ?</ul>

</div>

</template>


<script>

import store from '@/store'

export default {

name:'list',

store,

methods: {

? ?more(index){

? ? ? store.commit('detail', index)

? ? ?this.$router.push('/info')

}

},

computed: {

? ? pageLists(){

? ? ? return store.state.lists

? ? ?}

? ?},

}

</script>

<style scoped>

</style

Info.vue

<template>

<div>

? ?<div v-for="(item, index) in pageLists"

? ? ? ? ? ?:key="index"

? ? ? ? ? v-show="index == current">

? ? ? ?<span>{{item.title }}</span>

? ? ? ?<p>{{ item.content }}</p>

? ?</div>

</div>

</template>

<script>

import store from '@/store'

export default {

? ?name:'info',

? ?store,

? ?data(){

? ?return {

? ? }

? ?},

? computed:{

? ?pageLists(){

? ? ? ?return store.state.lists

? ?},

? ?current(){

? ? ?return store.state.number

? }

}

}

</script>

<style scoped>

</style>

store.js

import Vue from 'vue';

import Vuex from 'vuex';

Vue.use(Vuex)


export default new Vuex.Store({

? ? ?state: {

? ? ? ? ?lists:[],

? ? ? ? number:null

? ? ?},

? ?mutations: {

? ? ? addList(state, value){

? ? ? ? ?state.lists.push(value)

? ? ?},

? ? detail(index){

? ? ? state.number = index

? ?}

},

actions: {


},

});



正在回答

1 回答

我覺得是你store.js里面,detail方法沒有接受 state 作為第一個參數(shù):

detail(state,index){

? ? ? state.number = index

}

vuex-mutations你可以看一下文檔


1 回復 有任何疑惑可以回復我~
#1

淡水狗 提問者

謝謝,是的。是漏了這個參數(shù)。已經(jīng)解決
2019-05-07 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

關(guān)于list組件點擊到info組件詳情中報錯 state is not defined,如果刪去store.commit(),不報錯但又顯示全部列表內(nèi)容

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號