当按下可按组件的子组件(例如图像)时,传递给 onPress 属性的函数不会在 android 上执行。在 iOS 上按预期工作。
0.63.2
调用该函数并触发效果(警报)
https://snack.expo.io/@razorshnegax/6c7be3
代码示例:
import React from 'react';
import { View, Pressable, Image, Alert } from 'react-native';
export default class Index extends React.Component {
render() {
// The onPress function fires in iOS, but not android
return (
<View>
<Pressable onPress={() => {Alert.alert("Yeep")}}>
<Image source={require('./greatknight.png')} style={{
// So that the image is more centered
top: 100,
left: 100
}}/>
</Pressable> …Run Code Online (Sandbox Code Playgroud) 我应该期望我的 expo-react-native + nextjs 应用程序在安装并添加“next-images”插件后构建,就像文档所说的那样,但在构建时我被 7 次出现相同的错误所阻止:
“错误:图像导入“./assets/X.png”
不是有效的图像文件。图像可能已损坏或格式不受支持。”此错误不仅出现在我自己的代码中,还出现在我安装的软件包(特别是反应导航)中的代码中
### 环境
expo-env-info 1.0.5 环境信息:系统:操作系统:Linux 5.15 Debian GNU/Linux 11(牛眼)11(牛眼)外壳:5.1.4 - /bin/bash 二进制文件:节点:16.17.0 - /usr/ local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.15.0 - /usr/local/bin/npm Watchman: 20220528.183901.0 - /usr/local/bin/watchman npmPackages: expo : ^47.0.0 => 47.0.8 反应:18.1.0 => 18.1.0 反应-dom:18.1.0 => 18.1.0 反应本机:0.70.5 => 0.70.5 反应本机网络: ~0.18.7 => 0.18.10
Expo Workflow: managed
Run Code Online (Sandbox Code Playgroud)
ChromeOS 版本 102.0.5005.189(官方版本)(64 位)和 CodeSandbox 项目:最新浏览器版本
@react-navigation/elements:154 错误:图像导入“./assets/back-icon-mask.png”不是有效的图像文件。图像可能已损坏或格式不受支持。
./AppbarBackIcon:66 错误:图像导入“../../assets/back-chevron.png”不是有效的图像文件。图像可能已损坏或格式不受支持。
你明白了
链接到 repl。这个 repl 是我的开发环境,删除了我的所有代码。repl 应该在启动时自动运行。如果没有,运行命令 …