您可能需要設置React才能使用ReactInjection接受許多AMP指令。
完成之後,React生成的HTML將包含它。
import { DOMProperty } from 'react-dom/lib/ReactInjection'
DOMProperty.injectDOMPropertyConfig({
Properties: {
'[class]': DOMProperty.MUST_USE_PROPERTY
}
})
UPDATE(AUG-25-2017):
上面的代碼解決了像DIV,UL,跨度正規的HTML標籤的情況下,等
我目前存在[src]屬性在自定義放大器列表中的問題。 React代碼不會爲自定義標籤注入DOM屬性,代碼認爲以'['開頭的屬性不是「安全的」,並將其從「amp-list」中移除,而不管injectDOMPropertyConfig的設置如何。
沒有爲陣營16 RFC將解決此問題:https://github.com/facebook/react/issues/10399
我也放置在一個問題: https://github.com/facebook/react/pull/10385
常量ampProps =類=>({ [類] :'foo.bar', }); return
重點是在支架中有括號。你提出的解決方案不會那樣做 –
這有幫助嗎? https://github.com/zeit/next.js/blob/master/examples/with-amp/pages/_document.js –