android - 反应:a.href 在我的 index.jsx 文件中不起作用
问题描述
我有一个处理 deepLink 的 index.jsx 文件。我的目标是当我在这个重定向页面上时,检测是否安装了应用程序。如果已安装,则打开应用程序,如果没有转到 PlayStore。
目前,当我在这个页面上时,它只是坐在上面什么都不做。a.click() 函数由于某种原因无法正常工作,并且不知道为什么。
const Redirect = () => {
const os = getOs();
const redirectToApp = () => {
if (os === 'android') {
const a = document.createElement('a');
a.href = 'Intent://open/#Intent;scheme=lxxxxx;package=com.txxxxx.lxxxxx;end';
a.click();
}
};
window.onload = redirectToApp();
return (
<Wrapper>
<RedirectPanel p={8}>
<Flex alignItems="center" flexDirection="column">
<H3 mb={2} textAlign="center">
Redirecting to MobileApp
</H3>
<RedirectImg />
<Text fontSize="18px" textAlign="center">
Please wait a few moments
</Text>
</Flex>
</RedirectPanel>
</Wrapper>
);
};
在我的 android 设备上,我打开了一个 js 编译器并运行以下代码:
const a = document.createElement('a');
a.href = 'Intent://open/#Intent;scheme=lxxxxx;package=com.txxxxx.lxxxxx;end';
a.click();
很好用。如果已安装,则打开,否则将转到 PlayStore。但在我的 index.jsx 中它不起作用。请寻求帮助!!!
解决方案
推荐阅读
- javascript - (Firebase / Cloud Functions)PayloadTooLargeError:queryparse 参数过多
- typescript - 有问题
- 使用 Angular 6 和 Typescript
- python - PySide2:如何使装饰槽在其工作线程上执行?
- python - 使用 python 中的高级选项复制 7zip gzip
- firebase - 使用当前 userId (auth.uid) 在文档中设置 createdBy 字段
- ruby-on-rails - 使用 will_paginate 对列进行二次排序
- python-3.x - TypeError:在与 postgresql 连接的 python 中的字符串格式化期间,并非所有参数都转换了
- .net-core - 如何配置 Kestrel Web 服务器以使用我的生产服务器的 IP 地址?
- javascript - 并行承诺的自定义错误处理
- ruby-on-rails - 如何将类名和方法添加到rails logger