使用react過程看到這樣的寫法,有點神奇,希望各位大神解釋一下

時間 2021-06-12 15:24:27

1樓:呂立青-JimmyLv

Spread Attributes #

Now you can use a new feature of JSX called spread attributes:

varprops

={};

props

.foo=x

;props

.bar=y

;var

component

=

/>;The properties of the object that you pass in are copied onto the component's props.

You can use this multiple times or combine it with other attributes. The specification order is important. Later attributes override previous ones.

varprops=;

varcomponent

=

foo=

/>;console

.log

(component

.props

.foo

);// 'override'

後邊兒的 prop 會覆蓋前面的同名 key 的 value,最開始用在 Array 上,ES6 已經實現。而現在 JSX 進一步在 Object 上也可以採用同樣的寫法,但是在 ES7 中才可能會正式納入規範。

使用React框架還用jQuery的外掛程式可行嗎?

沉默 你這個問題就像我電腦裝了360,還可以裝金山毒霸嗎,能裝是能裝,但是大部分功能重複不覺得多此一舉嗎,ajax用axios代替,狀態redux,元件庫可以用用國內的antd,或者國外的庫 Jooger 當然可以,但是不推薦,看你目的 如果你只是為了完成工作,隨便用,不怕坑多,反正後面又不是我維護...

Java靜態區的使用過程是這樣的嗎?

ScienJus 主要說一下第三點 static String object new String object test object存放在方法區,new String object test 顯然是在堆記憶體中開闢了一片新空間。那麼new String object test 與常量池中的 ob...

使用 OmniOutliner 的過程中有那些心得值得分享?

oswin zong 我現在工作基本離不開它,原來的時候omnifocus會用得多一些,現在基本專案規劃都在outliner裡面做了,很純粹的寫作體驗,也有很好的邏輯梳理方式 Sophia Xu 多圖預警 已經是比較早的問題了,現在看到,說一下我的使用經驗。我的用途基本上是以讀書筆記為主,在這個場景...