Using Vue to develop WebApp, an Android phone comes with a fallback key to solve problems

Source: Internet
Author: User

First of all, let me explain why I write this essay;

Because we write the WebApp, on the Android phone, press the fallback button, will quit the app, go back to the desktop, and not like the native app, there will be a hint, for example, "Press again to quit the app" this hint,

Press the return button once to go back to the desktop, which is obviously not what we want, nonsense ends, the following code;

Mui.init ({keyeventbind: {backbutton:true//Close Back button listener});////////////  processing logic: Within 1 seconds, press the return key twice, then exit the application; var first = Null;mui.back = function () {//First button, prompt ' press again to exit Apply ' if (!first) {first = new Date (). GetTime (); Press again to exit the application ');//Give Hint History.go (-1)//fallback to previous page settimeout (function () {//1s after first = null;}, 1000);} else {if (New Date (). GetTime ()-First < 1000) {//If two times the pressed time is less than 1s,plus.runtime.quit ();//Then quit the app
} } };

As long as you add this code to the index.html, you can implement it.

|--------------------------------------Forget

|-----------------------------------------.

|--------------------------------------------A

|-----------------------------------------------pieces

|---------------------------------------------------Things

We also have to introduce a JS file, or Mui.init, will be reported MUI can not find the error

<script type= ' text/javascript ' src= './static/mui.min.js ' ></script>

That's all, No.

Oh, again Friday, tomorrow can sleep late, happy

Using Vue to develop WebApp, an Android phone comes with a fallback key to solve problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.