cms之day2(vue router子路由、debugger、mongoose返回指定字段)

本文介绍了Vue.js CMS开发的第二天学习内容,涵盖了子路由的配置与使用,如何利用router的name属性进行导航,以及在Vue项目中应用debugger进行调试。在Node应用程序生成器部分,讲解了如何使用Mongoose查询并返回指定字段。
摘要由CSDN通过智能技术生成

day2

1.vue ant-design前端

1. vue router子路由
const routes=[
    {path:"/demo1/:id",component:demo1,props:true},//props为true时,可以将动态路由的值传递给相应的组件
    {path:"/demo2",component:demo2},
    //{path:"/demo3",component:demo3,name:"test"},//name属性是给路由起别名,方便用js的方式去跳转
    {path:"/demo3/:id",component:demo3,name:"test"},//name属性是给路由起别名,方便用js的方式去跳转
    {path:"/demo4",component:demo4,children:[
        {path:"demo4-1",component:demo4a}
    ]},//name属性是给路由起别名,方便用js的方式去跳转
]
2. router 下的name属性用法

传送门

3. vue项目使用debugger

​ 在package.json\eslintConfig\rules

  "rules": {
      "no-debugger": "off",
      "no-console": "off"
    }

2. node 应用程序生成器

1. mongoose查询返回部分字段
  const result = await ManagerModel.find({}, ['_id', 'username', 'email', 'mobile', 'status'])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue RouterVue.js 官方的路由管理器,用于实现单页面应用(SPA)中的路由功能。它可以帮助我们在不同的 URL 地址之间进行切换,并且可以根据不同的路由配置加载不同的组件。 在 Vue Router 中,我们可以通过配置路由的 `children` 属性来实现动态添加路由。具体的步骤如下: 1. 首先,在父路由的配置中,定义一个空的 `children` 数组,用于存放动态添加的路由。 2. 在需要动态添加路由的地方,使用 `router.addRoutes()` 方法来添加路由。这个方法接受一个包含路由配置的数组作为参数。 下面是一个示例代码,演示了如何使用 Vue Router 动态添加路由: ```javascript // 父路由配置 const parentRoute = { path: '/parent', component: ParentComponent, children: [] // 空的 children 数组 } // 动态添加路由 const childRoutes = [ { path: 'child1', component: Child1Component }, { path: 'child2', component: Child2Component } ] // 在需要添加路由的地方调用 addRoutes 方法 parentRoute.children = childRoutes // 注册路由 router.addRoutes([parentRoute]) ``` 在上面的示例中,我们首先定义了一个父路由 `parentRoute`,其中的 `children` 数组为空。然后,我们定义了一个包含路由配置的数组 `childRoutes`,其中包含了两个路由。最后,我们将 `childRoutes` 赋值给 `parentRoute` 的 `children` 属性,并通过 `router.addRoutes()` 方法将父路由注册到 Vue Router 中。 这样,当访问 `/parent/child1` 或 `/parent/child2` 时,对应的组件 `Child1Component` 和 `Child2Component` 将会被加载。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值