首页 > 解决方案 > 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 };

标签: typescript

解决方案


该功能被描述为隐藏安装按钮。所以不要在这里调用完全相同的函数。您必须找到一种方法将按钮隐藏在那里。


推荐阅读