Home  >  Article  >  Web Front-end  >  What should I do if uniapp does not return when using web-view?

What should I do if uniapp does not return when using web-view?

PHPz
PHPzOriginal
2023-04-14 13:33:242347browse

Uniapp is a very powerful cross-platform development framework, which allows us to only write one code and run it on multiple platforms. Among them, using web-view to embed Web pages is a very common requirement. However, sometimes when using web-view to embed a page, there may be a problem that cannot be returned.

This problem may occur on some Android phones. When we open a page in web-view and click the back button, the page will not return to the previous page, but will exit the application directly. This is a very troublesome problem for people who use web-view to develop applications.

The way to solve this problem is actually relatively simple. We only need to add some parameters to the web-view. The specific implementation method is as follows:

<template>
  <div class="container">
    <web-view src="https://www.example.com" @message="onMessage" :plus="plus"></web-view>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        plus: {
          android: {
            hardwareAccelerated: true,
            useDefaultIndicator: true,
            // 添加以下两个参数即可
            supportMultipleWindows: true,
            setSupportMultipleWindows: true,
          },
        },
      }
    },

    methods: {
      onMessage(e) {
        console.log(e.detail)
      },
    },
  }
</script>

As shown in the above code, add two parameters supportMultipleWindows and setSupportMultipleWindows to the web-view to solve the return problem. These two parameters tell web-view to support multiple pages, so that it can return to the previous page correctly.

In short, when developing using Uniapp, when calling the web-view component to embed in a web page, you need to pay attention to adding these two parameters to avoid the problem of being unable to return to the previous page.

The above is the detailed content of What should I do if uniapp does not return when using web-view?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn