Polymer 2.0: What are the prerequisites? [closed]

2019-09-21 09:59发布

I'm relatively new to web development and have a basic understanding of JavaScript (loops, functions, objects) and recently I started learning Polymer 2.0 and I have been struggling with it for a while now.

So I definitely need to brush up my skills. Please provide some resources that I should refer before trying out Polymer again.

What I'm struggling with:

  1. documentation, which seems too complex.
  2. Passing object data from one custom element to another and using functions like fire and dispatch.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-21 10:30

well, i would suggest you to try 1.8 polymer first. I have been developing in javascript for 2 years and 1 year in polymer. Few weeks ago i tried polymer 2.0 and i have to say that it is completely like in hell (at least for me)

There is no complete documentation for all elements and polymer itself. Everything i needed i had to find on stackoverflow, some properties has changed and noone ever noticed about that. So Polymer 2.0 is for beginner really hard to understand. Even more when you don't know javascript itself.

Starting with Polymer 1.8 is propably better solution, since you don't need to use ES6 (https://www.youtube.com/watch?v=UBmQpD2RrPU). (I know, there are hybrid elements, but main purpose is to use class definiton). ES6 is really amazing and if you really want to develop in polymer 2.0, you should learn it first. But it makes everything much more harder for someone, who never heard about OOP (what is OOP and how to use it in JS?).

About your questions:

Documentation seems to complex:

This is propably not right. You just need to make some things clear. Polymer itself just connecting elements. Polymer's functions are used to pass data across application, work with DOM, and with variables and so on. As you can see in documentation there aren't much methods (in compare to size of Polymer).

Just to tell you something about elements, Polymer team created elements with prefixes (iron, paper, neon etc. ) Iron elements are mostly used for some logic, they do something that user can't see or they aren't styled in material-design.

Paper elements are displaying something. with material-design based graphics.

and so on. You can everything about elements find here: https://elements.polymer-project.org/

your second question:

Passing object data from one custom element to another

This is already something you need to understand on yourself. Just follow easy step-by-step tutorial from Polymer site. I could write a book here already about this. Once, I had to teach my co-worker who wasn't so good in javascript (just student) and it was pain. We spend more than 3 hours of sitting in front of screen and even after that he wasn't able to do easy tasks alone.

and your last question

using functions like fire and dispatch

As i said. I have been developing apps in Polymer for 1 year and these functions are rarely used in my code. function Fire is great, if you have some nested elements or somewhere in DOM tree and from 1 element you need to call another one and tell him something interessting. It's broadcasting to all elements and these elements can catch this broadcast and accept it.

This is a little bit long and maybe a forget something, so ask if you need something more

查看更多
登录 后发表回答