ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.02k stars 13.51k forks source link

Why is there no problem with the development mode after using the iframe tag, but when running on a real machine, an error occurs? #29625

Closed niemingwang closed 4 months ago

niemingwang commented 4 months ago

Ionic version:

[x] 4.x [ ] 5.x

I'm submitting a ...

[x] bug report [ ] feature request

Current behavior: Why did I use the iframe tag and set src to a remote address (a web app built by vite+vue3) in the Ionic code? After executing npx cap open Android and starting Android studio, I ran the project on the real machine for debugging. When I switched to the page where the iframe is located, I would get an error message: Capacitor/Console io.ionic.starter E File: https://myapp.com/assets/index-BYIDgwBY.js -Line 9- Msg: Uncaught SyntaxError: Unexpected token. Why is this?

Expected behavior:

Steps to reproduce:

Related code:

<template>
  <ion-page>

    <ion-content :fullscreen="true">
      <iframe style="width: 100%; height: 100%; border: none" src="https://myapp.com" />
    </ion-content>
  </ion-page>
</template>

<script setup lang="ts">
import { IonContent,IonPage } from '@ionic/vue';
import { useIonRouter } from '@ionic/vue';

const ionRouter = useIonRouter()

window.addEventListener('message', (event) => {
  if (event.data && event.data.type === 'FROM_WEBVIEW') {
    ionRouter.back()
  }
});
</script>

Other information:

Ionic info:

Capacitor/Console io.ionic.starter E File: https://myapp.com/assets/index-BYIDgwBY.js - Line 9 - Msg: Uncaught SyntaxError: Unexpected token ?
niemingwang commented 4 months ago

And I noticed that if the src of the iframe I referenced is a web app built on Vue2, there is no such error and the program runs normally

sean-perkins commented 4 months ago

Hello @NieBarBar these types of support/debugging requests are best to ask in the Discord. The team uses Github issues for bugs within Ionic Framework (the UI components).

Based on your described issue, it could be a number of factors, but unlikely to be related to the web components. If you are able to reproduce this issue specific to Ionic web components, please open a new issue with a minimal reproduction.

Thanks!

ionitron-bot[bot] commented 3 months ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.