1 vue init webpack demo
2cnpm install
3cnpm install element-ui -S
4在main.js中引入
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
5cnpm i --save-dev vuex
import store from '@/store/store'
在store/store.js
import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex) const fund = { state:{ select_funds:[],//已选择的匹配基金 }, mutations:{ SELECTFUNDS(state,data){ if(data.length==0){ state.select_funds =[]; sessionStorage.setItem('select_funds',''); }else{ state.select_funds = Object.assign(state.select_funds,data) sessionStorage.setItem('select_funds', JSON.stringify(state.select_funds)); } }, }, actions:{ getTickets({commit,state},data){ // api.getTickersInfo().then(res=> { // res = res.data; // let arr = []; // if (res.code === 200) { // let data = res.data; // for(let i in data){ // arr.push({name:i,ticket:data[i][0],kind:data[i][1]}) // } // commit('TICKETSLIST',arr) // } // // }) } }, getters:{ selectFunds(state){ return state.select_funds; }, } } for(var item in fund.state){ if(item == 'tickets'){continue;} sessionStorage.getItem(item)?fund.state[item]=JSON.parse(sessionStorage.getItem(item)):false } export default new Vuex.Store({ state:{}, modules:{ fund }, mutations: { } })
5安装sass ,请看https://www.cnblogs.com/mengdiezhuangzhou/p/10196286.html
公用sass 文件,抢看 https://www.cnblogs.com/mengdiezhuangzhou/p/10195767.html