如何在Durandal路由器中使用splat参数?

编程入门 行业动态 更新时间:2024-10-25 11:26:45
本文介绍了如何在Durandal路由器中使用splat参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在查看的文章是 Durandal Router 。

在 mapAuto 下,它表示可以在URL #/ customers / 1 。并且viewmodel中的 activate 函数将能够检索参数数组。

Under mapAuto, it says we can pass splat parameter in the url #/customers/1. and the activate function in the viewmodel will be able to retrieve the parameter array.

我在这里建立了一条路线

I built a route here

router.mapRoute('view/:id', moduleId, 'Customer Details', false);

但是如何获取 id 激活函数?文档页面上没有示例。请帮助我们。谢谢。

But how can I obtain the id in the activate function? There is no example on the doc page. Please help us out. Thank you.

推荐答案

为您的Activate函数提供一个参数,可能命名为 data。

Give your activate function a single parameter, perhaps named something like "data".

传递给网址的ID将在激活函数中作为 data.id提供。

The id that was passed into the url will then be available within the activate function as "data.id".

var activate = function(data) { alert(data.id); };

更多推荐

如何在Durandal路由器中使用splat参数?

本文发布于:2023-11-25 14:15:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630088.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   器中   参数   如何在   Durandal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!