I am currently working on developing a lightbox/modal feature using Vue.js. After making significant progress, I have encountered the need to utilize existing functions from another Javascript/Jquery file. Due to the complexity of these functions, rewriting them in Vue is not a feasible option at this stage. The challenge I am facing now is how to access and integrate these functions into my project. I am unsure if I should import them as mixins or explore alternative approaches.
Presently, the code triggers an error message:
[Vue warn]: Property or method "lightbox" is not defined on the instance but referenced during render.
Here is a snippet of relevant code from my Vue component:
<template>
...
<i
class="fa fa-info-circle"
name="moreInfo"
aria-hidden="true"
@click="lightbox.showBasketHelpLightbox('servicePlan', true, 3)"
/>
...
</template>
<script>
...
import lightbox from '../../../legacy/static/js/lightbox';
export default {
name: "AddToCartModal",
components: {.....},
mixins: [....., lightbox],
....
}
</script>
Additionally, here is the pertinent code excerpt from lightbox.js:
// Code has been omitted for brevity
Despite attempting to add
export default {showBasketHelpLightbox, closeBasketHelpLightbox}
at the end of lightbox.js and importing these function names as mixins in the Vue component, issues arose due to the presence of the word default
in the file.