I am trying to use Fotorama (photo gallery) in my project on vue-cli. jQuery 3.5.1 and Fotorama installed using NPM. Code part:
<script>
import 'jquery'
import 'fotorama/fotorama'
export default {
// ...
}
</script>
I get this error:
Uncaught Fotorama requires jQuery 1.8 or later and will not run without it.
How to make it work?
I was doing:
Sorry, if there are errors in my question, my English bad. I ask this question on the subdomain of my community, but they could not help me. Perhaps there are other libraries that provide such an opportunity. The main thing is that they weigh a little and know how to load pictures when scrolling (not all at once)
I was able to solve this problem.
methods {
// add script tags to head
loadFotorama() {
let script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js';
document.documentElement.firstChild.appendChild(script);
},
loadJquery() {
let script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
document.documentElement.firstChild.appendChild(script);
}
},
created() {
this.loadJquery()
},
computed: {
// this property is true when the server sent links to the desired images
// images are added to the DOM using v-for
imagesLoaded() {
return this.$store.getters.getImagesLoaded
}
},
watch: {
imagesLoaded(val) {
if (val) {
// while fotorama loads from cdn server vue will create img tags using v-for
this.loadFotorama()
}
}
}
It works fine! Thanks to everyone who tried to help