简体   繁体   中英

binding with polymer lit-element 0.6.2 dosn't work

i have update version of polymer lit-element from 0.5.2 to 0.6.2 and the binding dosn't work what I wrong?

this the html:

 <html> <head> <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script> <script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script> </head> <body> <my-element feeling="good"></my-element> <script type="module" src="./index.js"></script> </body> </html> 

with old version 0.5.2 the code below worked

  import {LitElement, html} from '@polymer/lit-element'; class MyElement extends LitElement { static get properties() { return { feeling:{type:String} } } _render({feeling}) { return html ` i feel ${feeling}!`; } } customElements.define('my-element', MyElement); 

this with 0.6.2 :

 import {LitElement, html} from '@polymer/lit-element'; class MyElement extends LitElement { static get properties() { return { feeling:{type:String} } } render() { return html` now i feel ${this.feeling} !`; } } customElements.define('my-element', MyElement); 

I find that in version 0.6.2 is changed the function _render() to render() and for the proprerty if change in this.proprerty ..... but in render this.feeling is undefined....

can help me?

I am not sure what happend, but I delete the white-spaces before html ... tag in render().

Now it works fine. It was IDE that warned me that line must be not running.

  render() {            
    return html`  now i feel  ${this.feeling} !`;
  }       

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM