SoFunction
Updated on 2025-04-05

Vue implements the method that can have multiple router-views on the same page

When using Vue+Element to build a project, in order to avoid one page being too large, divide the content in the tab into multiple pages and display it using the same-level view

<el-tabs v-model="activeName" @tab-click="handleClick">
   <el-tab-pane label="User Details" name="first">
   <router-view></router-view>
   </el-tab-pane>
   <el-tab-pane label="User Group" name="second">
   <router-view name="second"></router-view>
   </el-tab-pane>
   <el-tab-pane label="User Permissions" name="third">
   <router-view name="third"></router-view>
   </el-tab-pane>
   <el-tab-pane label="User Information" name="fourth">
   <router-view name="fourth"></router-view>
   </el-tab-pane>
   <el-tab-pane label="Department Information" name="fifth">
   <router-view name="fifth"></router-view>
   </el-tab-pane>
  </el-tabs>

Define a name for router-view, and the default display does not need to be defined.

Then define components in the route,

path: '/admin/userManagement/userNew/userShow',
components: {
 default: AdminUserShow,
 second: AdminUserGroup
}

The default displayed name iscomponentsDefined as default

Details can be viewedOfficial Documentation

The above method of implementing the same page of vue can have multiple router-views is all the content I share with you. I hope you can give you a reference and I hope you can support me more.