Implementation ideas: Step 1: Component encapsulation of TabBar and TabBarItemAt this point, you can find that the basic layout of the page has been implemented, but the active state of the item click has not been implemented. Step 2: Pass the active image to TabBarItemIn order to prevent the replaced content from directly replacing the entire slot, so that the style defined on the slot is also affected by the replacement, it is best to define a div wrapper outside the slot Step 3: The combination of TabBarItem and routingStep 4: TabBarItem color controlIt is basically completed, but it is found that the repeated click path in the route will result in an error Cause of error: This is because the callback format of vue-router ≥ 3.0 is changed to promise. If no error is caught, this kind of error warning will appear in the console. Solution 1: Downgrade vue-router to version 3.0 npm i [email protected] -S Solution 2: Rewrite the push and replace methods on the Router prototype chain so that you don't have to add a catch every time you call the method. Write the following content in main.js: import Router from 'vue-router' const originalPush = Router.prototype.push Router.prototype.push = function push(location, onResolve, onReject) { if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) return originalPush.call(this, location).catch(err => err) } If the push modification still does not take effect, you can try the replace method, for example: const originalReplace = Router.prototype.replace; Router.prototype.replace = function replace(location) { return originalReplace.call(this, location).catch(err => err); }; Implemented with font iconsIntroducing font iconsuseSummarizeThis is the end of this article about vue encapsulation of TabBar component. For more relevant vue encapsulation of TabBar component content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: HTML table border control implementation code
>>: 4 flexible Scss compilation output styles
Purpose: Treat Station A as the secondary directo...
Apache Arrow is a popular format used by various ...
1. Installation Tip: There is currently no offici...
This article example shares the specific code for...
<body style="scroll:no"> <tabl...
1. Python installation 1. Create a folder. mkdir ...
Table of contents Development Environment Game en...
In the horizontal direction, you can set the alig...
1. Always use :key in v-for Using the key attribu...
<br />When uploading on some websites, a [Se...
Table of contents 1. Introduction 2. Usage 3. Dev...
1. Background 1. The front end uses vue + vuex + ...
Table of contents need: Problems encountered: sol...
Normally, you'll need to read everyone's s...
The vue project implements an upgraded version of...