Polymer global variables

后端 未结 2 1320
借酒劲吻你
借酒劲吻你 2020-12-01 11:43

I\'m working on a Polymer app, which is pulling data from a RESTful API and using it to construct the interface. A specific area I\'m stuck on conceptually is the implementa

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 11:49

    @Zreptil has asked for an example above, and since I had to experiment with this anyway I built one based on Tim Stewart's answer and the Polymer documentation.

    Complete Example: http://jsbin.com/figizaxihe/1/edit?html,output

    I had some troubles with dashes in the id (id="global-variable") so I also added an example for that.

    The element definition

    
    
    
    

    Use it inside a polymer element

    
    
    
    

    Use it outside a polymer element

    
    

    Pay attention with dashes/hyphens

      

    and since that took me a while to realize - dashes are not directly supported...

    Polymer 1.0

    See Polymer 1.0 Global Variables for a polymer 1.0 solution if interested.

提交回复
热议问题