扫描QR码后,在新页面上打印信息

发布于 2025-02-13 02:40:03 字数 100 浏览 5 评论 0原文

我正在研究QR代码扫描仪。扫描QR码后,我可以使用警报在屏幕上打印信息。但是我想要的是在摄像机中扫描新页面后在新页面上的代码中打印信息。

打开相机并扫描QR码时要采取的措施

I am working on a QR Code scanner. As soon as the QR Code is scanned, I can print the information on the screen with an alert. But what I want is to print the information in the code on a new page as soon as it is scanned in the camera.

Actions to be taken when opening the camera and scanning the qr code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

極樂鬼 2025-02-20 02:40:03

首先,我们创建一个新页面,其中QR码中的信息将被传输。然后,我们将我的app.js页面与stack导航器集成在一起,以在页面之间启用过渡。

function App() {
  return (
    <Stack.Navigator>
      <Stack.Screen name='QRScanner' component={Home} />
      <Stack.Screen name='Scanner' component={Scanner} />
      <Stack.Screen name='Scanned' component={Scanned} />
    </Stack.Navigator>
  );
}

然后,我们进入“扫描仪”页面,从这里开始,我们将QR码转到扫描时的“扫描”页面。(此过程允许我们将QR码中的信息发送到“扫描”页面。

  const handleBarCodeScanned = ({ type, data }) => {
    setScanned(true);
    navigation.navigate("Scanned", { data });

  };

)最后一步,我们创建一个“过滤器”值,以在“扫描”页面上打印信息并将其显示在屏幕上。

const Scanned = ({ route }) => {
  const { data } = route.params;
  const filter = data.replace(/@/g, "\n");
  return (
    <View style={{ marginHorizontal: 25, marginVertical: 20 }}>
      <Text>{filter}</Text>
    </View>
  );
};

export default Scanned;

First of all, we create a new page where the information in our QR code will be transferred. Then we integrate my App.js page with Stack Navigator to enable transition between pages.

function App() {
  return (
    <Stack.Navigator>
      <Stack.Screen name='QRScanner' component={Home} />
      <Stack.Screen name='Scanner' component={Scanner} />
      <Stack.Screen name='Scanned' component={Scanned} />
    </Stack.Navigator>
  );
}

Then we come to the 'Scanner' page and from here we make the QR code go to the 'Scanned' page when scanned.(This process allows us to send the information in the QR Code to the 'Scanned' page.)

  const handleBarCodeScanned = ({ type, data }) => {
    setScanned(true);
    navigation.navigate("Scanned", { data });

  };

As a final step, we create a 'filter' value to print the information on the 'Scanned' page and make it appear on the screen.

const Scanned = ({ route }) => {
  const { data } = route.params;
  const filter = data.replace(/@/g, "\n");
  return (
    <View style={{ marginHorizontal: 25, marginVertical: 20 }}>
      <Text>{filter}</Text>
    </View>
  );
};

export default Scanned;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文