小编tan*_*aum的帖子

打字稿和谷歌AMP?类型“JSX.IntrinsicElements”上不存在属性“amp-img”

我有一个运行快速服务器的节点项目,当在 url 中查询带有 /amp 的新闻文章时,会返回该文章的 amp 版本。

由于客户的要求,这些 amp 文章是使用 React 组件构建的,这些组件最终呈现为静态标记。这是其中一个组件:

import * as React from 'react';
import { Article_modulesByArticleId_edges_node } from '../../data/__generated__/Article';

// GraphQL auto generated type for the data that is sent to this component 
type Props = {
	module: Article_modulesByArticleId_edges_node;
};

export default (props: Props) => {
	const image = props.module.image;
	if (!image || !image.url || !image.title || !image.copyright) {
		return "";
	}

	return <amp-img alt={image.title} src={image.url} ... />
};
Run Code Online (Sandbox Code Playgroud)

问题?该项目还使用了我不太熟悉的打字稿。

当我尝试使用自定义 AMP-HTML 元素时,打字稿会抛出以下错误消息:

[ts] Property …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs amp-html

9
推荐指数
1
解决办法
6068
查看次数

标签 统计

amp-html ×1

javascript ×1

reactjs ×1

typescript ×1