vue 踩坑记录

1.绑定双击事件用 @dblclick 不要用@ondblclick  在vue中@=on

2.Vue中路由跳转踩坑。

比如我的路由如下定义

routes: [
    {
      path: "/", name: "index", component: Index
    },
    {
      path: "/gallery", name: "gallery", component: Gallery,
      children: [
        {
          path: "top/:top/skip/:skip", name: "gallerys", component: Gallery,
          children: [
            {
              path: "query/:query", name: "search", component: Gallery
            }
          ]
        }
      ]
    }
  ]

然后这么调用“search”这个路由,这个路由里面的参数是动态的,如果“this.searhkey”这个值为空,也可以这么说,只要params里面有一个值为空,都无法定位到“search”路由,会自动跳转到根路由“Index”

this.$router.push({ name: "search", params: {top: "5", skip: "0", query: this.searhkey } });

3.Vue 路由报错,如: missing param for named route "mysearchpackage": Expected "query" to be defined,这句话的意思是,在使用“mysearchpackage”的时候,没有给“query”这个参数赋值,全局搜索“mysearchpackage”这个路由,查看是否在使用该路由的时候少给参数“query”赋值

转载于:https://www.cnblogs.com/fqybzhangji/p/7210530.html

你可能感兴趣的:(vue 踩坑记录)