<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.jsexport const CHANGESTYLE = 'CHANGESTYLE'問題是alert可以彈出來,為什么styleKey 是undefined,還有為什么CHANGESTYLE事件 默認的參數是state
添加回答
舉報
0/150
提交
取消