Applying Behaviors with JS Mixins in Polymer 2

后端 未结 2 728
暗喜
暗喜 2020-12-30 12:51

I want a custom element I\'m defining to have the Polymer.IronScrollTargetBehavior in Polymer 2.

In Polymer 1, this can be done by adding it to the

2条回答
  •  有刺的猬
    2020-12-30 13:14

    You can use the Polymer 2 hybrid behaviours as mixins by extending Polymer.mixinBehaviors(behaviors, klass) where
    - behaviors is the Behavior object or array of behaviors
    - klass is the Element class.

    i.e.

    
      
      
    
    

    For more detailed information search the Polymer source code for mixinBehaviors method: polymer/lib/legacy/class.html

    worth reading: https://www.polymer-project.org/2.0/docs/upgrade#mixins

提交回复
热议问题