Search code examples
javascriptvaadinpolymer-2.xvaadin10

How to use third party javascript plugin in polymer 2.x


Hello guys i have a trouble with using javascript plugin on polymer. How i include and use javascript plugin in my project.

@JavaScript("js/main.js")

this is my java class using javascript annotation. But its not working.

Using javascript annotation in my class.

And here is my html

<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<dom-module id="main-page">
    <template>
        <style>
</style>
 </template>
    <script>
    class MainPage extends Polymer.Element {
        static get is() {
            return 'main-page'
        }
    }

    customElements.define(MainPage.is, MainPage);
    </script>
</dom-module>

Any advice ?


Solution

  • I suspect the JS file is not in the directory specified in the annotation. Here is an example of project structure demonstrating @JavaScript

    enter image description here

    When you run that example, you should see the following in the browser.

    enter image description here

    You can find the sample project here: https://github.com/oluwasayo/demo-flow-js