在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue state在method中使用報undefined

vue state在method中使用報undefined

vuex中用mapstate映射state(代碼里面用的是attributeData: state => state.kickoff.attributeData),在模板<template v-for="(attritem, index) in attributeData">使用state可以訪問到state的數(shù)據(jù),但是在method里面用this.attributeData并打印,都是undefined。想問下怎么取不到attributeData值

回答
編輯回答
傲寒

template獲取數(shù)據(jù),method里面獲取數(shù)據(jù)機制不一樣的,用computed屬性做下轉化:

computed:{
    attrData(){
        return state.kickoff.attributeData
    }
}
2018年4月19日 16:16