1. Defined in interface function (api/index.js):( Remember, there must be no {}, Otherwise, the parameters are wrong )
// export const
reqShopList=({geohash,keyword})=>ajax(base_url+'/search_shops',{geohash,
keyword}) export const
reqShopList=(geohash,keyword)=>ajax(base_url+'/search_shops',{geohash, keyword})
2. stay mutation-type Definition of Li :
export const RECEIVE_SEARCH_SHOPS='receive_search_shops'// Array of merchants receiving search
3. stay mutation in :
[RECEIVE_SEARCH_SHOPS](state, { searchshops }) { state.searchshops =
searchshops; },
4. stay action in :( Receive parameters )
async searchShopGoods({ commit ,state},keyword) { const geohash =
state.latitude + ',' + state.longitude; const result = await
reqShopList(geohash,keyword) if (result.code === 0) { const searchShops =
result.data commit(RECEIVE_SEARCH_SHOPS, { searchShops }) // If the callback function that receives the message is passed in the component ,
After data update , Call callback notification called component // callback && callback() } },
5. Where information is needed vue In the document :
search(){ // Get search keywords const keyword=this.keyword.trim(); // Search if(keyword){
this.$store.dispatch('searchShopGoods',keyword) } }
6. Display data
Technology