angularjs - 打字稿:呈现自定义脚本标记引发错误 TS1005:“}”预期
问题描述
我有一个类MyScriptTag.tsx
,我打算在其中呈现对主布局中包含的服务库的调用。这是它的样子:
import React from 'react';
import * as Radium from 'radium';
import { getUser } from '../actions/user';
const MyScriptTag = () => {
return (
<script>
window['ExtLibrary'] = window['ExtLibrary'] || { _queue: [], Push: function (o, p) {this._queue.push({ type: o, data: p }); } };
ExtLibrary.Push('User', {
eMail: getUser().email
});
</script>
);
};
const Component = Radium(MyScriptTag);
export default Component;
MainLayout.tsx
它通过以下方式包含在一个类中:
class MainLayout extends React.Component<any, any> {
render() {
const { isLoggedIn, isLoggingIn } = this.props;
return (
<div>
<section style={[styles.base]}>
...
<MyScriptTag />
</section>
</div>
)
}
}
代码未编译,这是我收到的错误消息:
error TS1005: '}' expected.
可能是新事物,因为我以前没有使用过打字稿。但我找不到解决方法,谷歌搜索也无济于事。
解决方案
你错过了你}
的结尾MainLayout.tsx
,要关闭class
。
推荐阅读
- amazon-web-services - 用于 EC2 的 AWS 传出请求 ELB
- angular - 当 [选中] 在 mat 单选按钮中应用时,OnChange 不起作用
- hyperlink - 如何通过pycharm中的内容链接到一行代码?
- flutter - 如何在颤动中点击翻转按钮和旋转按钮时更新视频?
- python - 无法从 javascript 网页中抓取多个相关的下拉列表
- terraform - 如何在 terraform 中将条件资源引用到另一个资源上
- .net - 当我计划在带有 AKS 的 Windows 容器中运行控制台应用程序时,是否需要下载整个 .NET Framework 运行时映像?
- python - 如何为 PyTorch 的预训练 VGG16 添加权重归一化?
- javascript - 替换所有其他特定字符串
- c++ - 可以映射 tcp 客户端 fd 吗?