Polymer 1.0 paper-drawer-panel toggle is not working

后端 未结 4 1299
情话喂你
情话喂你 2021-01-24 02:17

\'my-layout\' code :




        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 02:32

    There are a few things I noticed in your code.

    1. In your my-layout code you should also be importing polymer.html
    2. Which version of Polymer are you using? Since you are using the webcomponents-lite.min.js and the title states Polymer 1.0, I am assuming you are using 1.0. In Polymer 1.0 elements are defined using instead of
    3. the toggle function in your script is not necessary, the toggle works out of the box using the paper-drawer-toggle attribute on the paper-icon-button element.

    I am not sure of your directory structure but the following code works for me. I am assuming you have bower_components (including all polymer, iron, and paper elements) inside of your root. Also in your root I am assuming you have an elements directory containing your m-layout.html file. You should check your developer tools in your browser to check that all your resources are loading correctly and there are no errors. If so, then your import paths to the components are wrong.

    In your elements/m-layout.html:

    
    
    
    
    
    
    
    
    
    
    
    
    

    and this in main.jsp:

    
    
    
    
      
      
      
      
    
      My Test
    
      
      
    
      
    
    
    
    
      
    
    
    
    

    Also keep in mind, that the drawer (and therefore the toggle) is only activated when the screen is very small (mobile). To force the drawer behavior no matter what the screen size, you can force the narrow view by setting the force-narrow attribute: . Alternatively you can set the width at which the drawer should be activated, .

提交回复
热议问题