I am trying to share a method between multiple components and this method should access an attribute from the parent component. I am using VUE3, with script setup. I tried with “extend” but I couldn’t find how to extend a component with script setup. I don’t want to pass any parameter because in my real case I have many of them, too many. Thank you very much for the support
//TheComponent.vue
<template>
<div></div>
</template>
<script>
import common from './Common.js';
const x=7;
common.print();
</script>
//Common.js
const common={
print: function() {
alert(x);
}
}
};
export default common;