Можно через vuex. Отправляешь файл на сервер, сохраняешь его там, возвращаешь себе ссыль, ссыль сохраняешь в vuex.
<input type="file" class="form-control-file" id="image" accept="image/*" ref="md"
@change="imgAdd">
<img :src="news.image" class="card-img-top img-fluid" :alt="news.title">
computed: {
news() {
return this.$store.getters['news']
}
},
methods:{
imgAdd(event){
let data = new FormData();
const config = {
headers: {
'content-type': 'multipart/form-data'
}
};
data.append('file', event.target.files[0], event.target.files[0].name)
this.$axios.$post('/uploadImage', data, config)
.then((response) => {
this.$store.commit('news/changeImage',
response.link)
})
},
}