You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`modifyClientRenderOpts` is a runtime plugin hook provided by WinJS for modifying render options before client-side rendering. Through this hook, when using `Vue2`, you can customize core instances such as router, store, pinia, etc., to achieve highly customized application initialization.
601
-
602
-
#### Basic Usage
603
-
604
-
Export the `modifyClientRenderOpts` function in `src/app.js`:
605
-
606
-
```javascript
607
-
exportfunctionmodifyClientRenderOpts(memo) {
608
-
return {
609
-
...memo,
610
-
// Add or modify render options here
611
-
};
612
-
}
613
-
```
614
-
615
-
#### Parameters: memo Object
616
-
617
-
`memo` is the passed render options object, containing the following properties:
**Use Case**: Need to customize both router and store
746
-
747
-
```javascript
748
-
importcustomRouterfrom'./router/index';
749
-
importstorefrom'./stores';
750
-
751
-
exportfunctionmodifyClientRenderOpts(memo) {
752
-
return {
753
-
...memo,
754
-
router: customRouter,
755
-
store: store
756
-
};
757
-
}
758
-
```
759
-
760
-
##### Scenario 5: Modify Other Render Options
761
-
762
-
**Use Case**: Customize root element, modify base path, etc.
763
-
764
-
```javascript
765
-
exportfunctionmodifyClientRenderOpts(memo) {
766
-
return {
767
-
...memo,
768
-
// Customize root element
769
-
rootElement:document.getElementById('app'),
770
-
771
-
// Modify base path
772
-
basename:'/my-app/',
773
-
774
-
// Add custom properties
775
-
customOption:'custom-value'
776
-
};
777
-
}
778
-
```
779
-
780
-
#### Recommended Approach (Direct Pass)
781
-
782
-
```javascript
783
-
exportfunctionmodifyClientRenderOpts(memo) {
784
-
return {
785
-
...memo,
786
-
router: customRouter,
787
-
store: store,
788
-
pinia:createPinia()
789
-
};
790
-
}
791
-
```
792
-
793
-
#### Compatible Approach (Via Callback)
794
-
795
-
```javascript
796
-
exportfunctionmodifyClientRenderOpts(memo) {
797
-
constcallback= () => {
798
-
return {
799
-
store: store,
800
-
pinia:createPinia()
801
-
};
802
-
};
803
-
return {
804
-
...memo,
805
-
router: customRouter,
806
-
callback
807
-
};
808
-
}
809
-
```
810
-
811
598
### modifyConfig
812
599
813
600
Modify configuration. Compared to user configuration, this is the final configuration passed to WinJS. The passed `fn` receives config as the first parameter and returns it. Additionally, `fn` can receive `{ paths }` as the second parameter. `paths` contains various paths of WinJS.
0 commit comments