Vue dynamically add rout

I am trying to control vue permissions, but I have encountered some problems in adding routes dynamically. The code is as follows:
this is the main.js file

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue"
import App from "./App"
import router from "./router"
import ElementUI from "element-ui";
import { powerRouter } from "./router";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
Vue.config.productionTip = false
router.beforeEach( (to,from,next)=>{
  let newrouter;
  newrouter = powerRouter;
 
  router.addRoutes(newrouter)
  console.log(newrouter)
  console.log(router)
  next()

} )

/* eslint-disable no-new */
new Vue({
  el: "-sharpapp",
  router,
  components: { App },
  template: "<App/>"
})
< hr > < hr >

this is the routing file

import Vue from "vue"
import Router from "vue-router"
import HelloWorld from "@/components/HelloWorld"
import Index from "@/components/index"
import Login from "@/components/login"
Vue.use(Router)
const red = { template: "<div style="background-color:-sharpde5b5b;color:-sharpfff; font-size:30px;line-height:100px;text-align:center;">red</div>" }
const yellow = { template: "<div style="background-color:-sharpdee066;color:-sharpfff; font-size:30px;line-height:100px;text-align:center;">yellow</div>" }
const blue = { template: "<div style="background-color:-sharp6680e0;color:-sharpfff; font-size:30px;line-height:100px;text-align:center;">blue</div>" }

export default new Router({
  routes: [
    {
      path: "/login",
      name: "Login",
      component: Login
    }
  ]
})


export const powerRouter = [
  {
    path:"/",
    redirect:"/red",
    name:"Index",
    component:Index,
    children:[
      {
        path:"/red",
        name:"red",
        component:red
      }
    ]
  }
]

now the situation is to add dynamically, there is no response, and there is nothing wrong to ask for advice

Mar.03,2021

I feel that there is no need to do this like you. You can simply bring parameters to the route, and then adjust the page according to the parameters passed in the template. For more information, please see https://router.vuejs.org/zh-c.

.

and your so-called dynamic add route is just to write a template in advance and then call it when you need it

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-1b3b60d-2c27f.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-1b3b60d-2c27f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?