[英]How can I write an array to a file in nodejs and keep the square brackets?
[英]How can I write a Type Declaration for a JSX attribute from Google AMP that uses square brackets?
要使用 AMP 的綁定功能,您必須使用特殊屬性,這些屬性用方括號包裹元素的屬性並將其鏈接到表達式。 以下是 AMP 的示例:
<p [text]="'Hello ' + foo">Hello World</p>
<button on="tap:AMP.setState({foo: 'amp-bind'})">
問題是,目前沒有 @types/amp 並且 Typescript 在我的 JSX 中的第一個[
說[ts] identifier expected
拋出錯誤。 弄亂它我也有[ts] Left side of comma operator is unused and has no side effects.
這很可能可以通過正確的 Typescript 類型聲明來解決。 有什么建議?
根據amp-bind 組件文檔:
在編寫 XML(例如 XHTML、JSX)或通過 DOM API 編寫屬性時,屬性名稱中的括號字符 [ 和 ] 可能會出現問題。 在這些情況下,請使用替代語法 data-amp-bind-x="foo" 而不是 [x]="foo"。 例如:
<p data-amp-bind-text="'Hello ' + foo">Hello World</p>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.