Mixed development, embed the vue single page I wrote through webview, but found that $router.go (- 1) is invalid.

that"s the question!
mixed development, embed the vue single page that I wrote through webview, but found that $router.go (- 1) is invalid and can"t be used, but I have no problem in Android and browser


vue, you use vue route jump, $router.push ({name:'index',params: {}});


want to know how the landlord solved it? Ask for help


have you solved the problem

I found the problem. Because window.history.length is 1, you can't fall back when it is 1. You can ask Android and ios developers to write a method to call the native fallback

if (window.history.length == 1) {
    //    
        if (iphoneType === 'ios') {
    window.webkit.messageHandlers.nativeGoBack.postMessage({
                name: '-1'
            });
        } else if (iphoneType === 'Android') {
            window.jsCallOCFunction.nativeGoBack(-1);
        }
    } else {
        router.go(length)
    }

is probably through the route guard, caching the page's name to an array of localStorage when entering a page. Then read the array when you click back, and then jump through router.push ({name}) to achieve the fallback effect.


encounters the same problem, but this push method has a flaw. For example, when you use list state caching in keep-alive, the push method cannot be cached. After entering the details, you will not be able to reach the status of the previous browsing location when you go back.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf423f-31ee2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf423f-31ee2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?