0

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 ?

ssindelar
  • 2,833
  • 1
  • 17
  • 36
batgerel.e
  • 837
  • 1
  • 10
  • 31
  • 1
    I'm not fully sure I understand what you are trying to achieve. What is in main.js? Where are you importing the HTML file? If you are trying to create a custom HTML (Polymer) template that's bound to server side Java, this should be the right doc: https://vaadin.com/docs/v10/flow/polymer-templates/tutorial-template-basic.html – Marcus Hellberg Mar 13 '18 at 02:13
  • I need to use http://idangero.us/swiper/ this plugin into my project but i can't using it with vaadin – batgerel.e Mar 13 '18 at 02:28
  • @KhShuren-Erdene Can you please show your project's folder structure? – Sayo Oladeji Mar 13 '18 at 11:19

1 Answers1

2

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

Sayo Oladeji
  • 741
  • 4
  • 15
  • 28