How to import a local image in vuex store without using axios

14 Views Asked by At

I want to add a local image to the array products like this (https://i.stack.imgur.com/Mckgm.png) I've tried to do like chatpgt said but I still can't do it

This is the coding that chatgpt gave me

//This is in component
uploadImg(event){
  const image = event.target.files[0];
  this.addImage(image).then((imageUrl) => {
     this.product.image = imageUrl;
  });
},

//This is in mutations.js
SET_IMAGE(state, image) {
  state.products.image = image;
},

//This is in actions.js
addImage({ commit }, image) {
  commit('SET_IMAGE', image);
},

0

There are 0 best solutions below