Skip to content

how to use with vite in laravel 9?  #6

Description

@bhojkamal

How to Import on this on vite and laravel 9?

on /resources/js/bootstrap.js, I've used as

import "js-share;"

on view file I included the following code in the script.

var shareItems = document.querySelectorAll('.social_share');
for (var i = 0; i < shareItems.length; i += 1) {
    shareItems[i].addEventListener('click', function share(e) {
        return JSShare.go(this);
    });
}

I got errors like this on the console when I click the soical icon - twitter or any

Uncaught ReferenceError: JSShare is not defined
    at HTMLButtonElement.share ((index):956:9)
share @ (index):956

Even I changed on bootstrap.js to this

import * as JSShare from "js-share";
window.JSShare = JSShare;

is not working; same error on console.
So the actual error is JSShare is not defined when click on button.

What is the issue here, can you please figure it out?

Thanks in advance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions