typescript - TypeScript 找不到名称“hideInstallPromotion”
问题描述
我正在按照本指南https://web.dev/customize-install/安装带有按钮的 PWA,但 TypeScript 不喜欢hideInstallPromotion()
import React, { useState } from 'react';
import { Button } from './button';
function InstallPWA() {
const [loading, setLoading] = useState(false);
const install = async () => {
setLoading(true);
hideInstallPromotion(); // TyoeScript doesn't like this? Why?
console.log('install');
};
return (
<div className='InstallPWA'>
<Button onClick={install} >Install<button/>
</div>
);
}
export { InstallPWA };
解决方案
该功能被描述为隐藏安装按钮。所以不要在这里调用完全相同的函数。您必须找到一种方法将按钮隐藏在那里。
推荐阅读
- javascript - 使用 Redux 操作获取数据但无法将数据设置为本地状态
- windows - 如何对 Windows exe 文件进行二进制分析?
- kotlin - 首次运行时未定义迭代器值
- authorization - 为用户提供集中式身份验证服务器或每个微服务一个数据库?
- flutter - 在 google_maps_flutter 中获取相机当前位置的问题
- python - 'str' 对象没有使用 widget_tweaks 的属性 'field'
- visual-studio - 如何访问 Visual Studio 代码片段中的类名?
- java - 为什么@Valid 不起作用
- ios - 如何通过 NavigationLink 将 ForEach 数组索引传递到另一个 ForEach 而不会崩溃?
- android - 如何在 MVVM android 应用程序中使用存储库模式和实时数据正确排序列表?