Add anaOptions Moduel
This commit is contained in:
36
vuex_demo1/src/store/ana.js
Normal file
36
vuex_demo1/src/store/ana.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import axios from 'axios';
|
||||
import {nanoid} from 'nanoid'
|
||||
export default{
|
||||
namespaced: true,
|
||||
state: {
|
||||
analist:
|
||||
[
|
||||
{
|
||||
'id':0,
|
||||
ana:'花花世界迷人眼,没有实力别赛脸'
|
||||
}
|
||||
],
|
||||
},
|
||||
mutations: {
|
||||
addanalist(state,value){
|
||||
state.analist.push(value)
|
||||
}
|
||||
},
|
||||
actions:{
|
||||
axiosGetAna(context){
|
||||
axios.get('https://api.uixsj.cn/hitokoto/get?type=social')
|
||||
.then(res=>{
|
||||
context.commit('addanalist',
|
||||
{
|
||||
id:nanoid(),
|
||||
ana:res.data
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
showListLength(state){
|
||||
return state.analist.length
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,12 @@ import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import countOptions from '@/store/count'
|
||||
import anaOptions from '@/store/ana'
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
countOptions
|
||||
countOptions,
|
||||
anaOptions
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user