Click the blue text ╳ to follow us
Introduction
Effect Diagram

Usage Instructions
Arouter supports the following features:
● Supports routing navigation between pages;
● Supports parameterized navigation and callbacks;
● Supports configuring navigation interceptors;
● Supports pre-processing navigation;
Routing Navigation
import {Arouter} from "@ohos/arouteronactivityresult";Arouter.getInstance() .build("--/--") // The address to navigate to .navigation()
import {Arouter} from "@ohos/arouteronactivityresult";Arouter.getInstance() .build("--/--") // The address to navigate to .withParams({index:"--"}) .navigation()
import {NavigationCallback} from '@ohos/arouteronactivityresult'var callback:NavigationCallback = { onInterrupt(postcard){}, onArrival(postcard){}, onActivityResult(data){}}
import {Arouter} from "@ohos/arouteronactivityresult";Arouter.getInstance() .build("--")// The address to navigate to .navigationWithCallback(callback)
import router from '@ohos.router';if (postcard == null) { postcard = Arouter.getInstance().getPostcard(router.getState().path+router.getState().name); }
postcard.getNavigationCallback().onActivityResult(params)
Routing Interception
import {Postcard,IInterceptor,InterceptorCallback} from '@ohos/arouteronactivityresult';var iInterceptor:IInterceptor= { process(postcard:Postcard, interceptorCallback:InterceptorCallback) { // Select the page to intercept, if the path is present during the navigation, prompt for interception; if not, navigate directly. if (Postcard.getUri() == 'pages/transit') { // Select the dialog box AlertDialog.show( { message: 'Intercepted, click to continue navigation', primaryButton: { value: 'Cancel', action: () => { // Interrupt navigation interceptorCallback.onInterrupt(postcard) } }, secondaryButton: { value: 'Continue', action: () => { // Continue navigation interceptorCallback.onContinue(postcard); } }, } ) } else { // Continue navigation interceptorCallback.onContinue(postcard); } }}
import {registerInterceptor} from '@ohos/arouteronactivityresult';registerInterceptor(iInterceptor);
import {unregisterInterceptor} from '@ohos/arouteronactivityresult';unregisterInterceptor()
Arouter.getInstance() .build("--/--")// The address to navigate to .setGreenChannel(true) .navigation()
import {PretreatmentService} from '@ohos/arouteronactivityresult';var pretreatmentService:PretreatmentService = { onPretreatment(postcard:Postcard):boolean{ return true }}
Call the .setPretreatmentService() method before navigation to pass the pretreatmentService into the setPretreatmentService() method to complete the pre-processing functionality.
Arouter.getInstance() .build(this.router) .setPretreatmentService(pretreatmentService) .navigationWithCallback(callback)
Interface Description


Installation and Download
ohpm install @ohos/arouteronactivityresult
Source Code Link