<li v-for="(value, key) in iPhone6S.style"
@click="changeStyle(key)"
:class="{active: iPhone6S.activeStyleUrl == value}">
<span v-text="key"></span>
</li>
mutations.js:
const state = {
iPhone6S: {
name: 'Apple/苹果 iPhone 6S',
desc: '3D Touch、1200万像素照片、4k视频,强大功能于一身。',
price: '5288 - 6888',
isSelected: true,
style: {
'玫瑰金色': 'http://o8yu724qs.bkt.clouddn.com/iphone6s-rosegold-select-2015.png'
},
activeStyleUrl: 'http://o8yu724qs.bkt.clouddn.com/iphone6s-silver-select-2015.png',
storage: {
'16GB': 5288,
'64GB': 6088,
'128GB': 6888
}
},
cart: []
}
actions.js
import * as types from './types'
export default {
changeStyle: ({ commit }) => {
commit(types.CHANGESTYLE)
}
}
types.js
export const CHANGESTYLE = 'CHANGESTYLE'
问题是alert可以弹出来,为什么styleKey 是undefined,还有为什么CHANGESTYLE事件 默认的参数是state
至尊宝的传说
BIG阳