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

External Script Importing & Requiring Documentation #196

Open
zacnomore opened this issue Jun 5, 2019 · 3 comments
Open

External Script Importing & Requiring Documentation #196

zacnomore opened this issue Jun 5, 2019 · 3 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@zacnomore
Copy link
Contributor

There's a mismatch in the docs between the text and code sample. The text suggests that libraries need imported and requiring it while the code only imports it. Which is correct?

https://gridsome.org/docs/assets-scripts#using-an-external-library

If you want to use a external javascript library inside your component you can do so by importing the component and requiring it once vue components are mounted.

...

import moment from 'moment';

@zacnomore zacnomore added the invalid This doesn't seem right label Jun 5, 2019
@zacnomore zacnomore changed the title External Script Importing External Script Importing & Requiring Documentation Jun 5, 2019
@TerabyteTiger
Copy link
Member

Would it make sense to update this to something like:

If you want to use a external JavaScript library inside your component you can do so by importing the component and utilizing it once the Vue component has mounted.

@zacnomore
Copy link
Contributor Author

@12vanblart Thanks for the reply! I may have over-complicated this but I was focused on this part "importing the component and requiring it " thinking it meant require and import like this example:

import React from 'react';
import ReactDOM from 'react-dom';
import ReloadRoot from './components/ReloadRoot';
const render = () => {
  ReactDOM.render(
    <ReloadRoot />,
    document.getElementById('root')
  );
}

render();

if (module.hot) {
  module.hot.accept('./components/ReloadRoot', () => {
    require('./components/ReloadRoot').default;
    render();
  });
}

from this article.

@seansmyth
Copy link

I'm struggling with this too.

I don't know how to import a .js file I have sitting in my assets folder. Keep getting 404 even thought believe the path is correct.

It's not very clear at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants