Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 3 composition API #127

Open
prasetyo-jeanu opened this issue Sep 28, 2023 · 1 comment
Open

Vue 3 composition API #127

prasetyo-jeanu opened this issue Sep 28, 2023 · 1 comment

Comments

@prasetyo-jeanu
Copy link

I cant access htmlToPaper in vue 3 composition API

async function print() {
	row.value = rows.value[2];
	htmlToPaper("print"); // cant access this
}
@TrumanWwW
Copy link

@prasetyo-jeanu you can use provide/inject to access it, I've try it

/* your main.js*/
...
app.provide("$htmlToPaper", app.config.globalProperties.$htmlToPaper);
...
<script>
/*where you want to print*/
...
const $htmlToPaper = inject("$htmlToPaper");

const printThis = () => {
  $htmlToPaper("printArea");
};
</script>

It works !

ps: getCurrentInstance is deprecated in latest Vue version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants