1
我在玩Durandal 2.0入門工具包。一切工作正常,但我試圖包括'durandal/plugins/router
'模塊,頁面掛起。我想要的只是從我的viewmodel訪問當前路由和查詢字符串。在Durandal 1.2中,我可以訪問傳遞給activate()
函數的routeInfo,但現在該參數始終爲空。這在2.0中如何完成?Durandal 2.0路由器訪問
感謝
我在玩Durandal 2.0入門工具包。一切工作正常,但我試圖包括'durandal/plugins/router
'模塊,頁面掛起。我想要的只是從我的viewmodel訪問當前路由和查詢字符串。在Durandal 1.2中,我可以訪問傳遞給activate()
函數的routeInfo,但現在該參數始終爲空。這在2.0中如何完成?Durandal 2.0路由器訪問
感謝
到路由器的路徑在2.0已經改變,現在是plugins/router
。 在main.js中,您應該看到負責路徑映射的require.config
塊。
requirejs.config({
paths: {
'text': '../lib/require/text',
'durandal':'../lib/durandal/js',
'plugins' : '../lib/durandal/js/plugins',
...
});
編輯:由@EisenbergEffect
在谷歌組https://groups.google.com/forum/#!topic/durandaljs/jRzCQzU5XIg 回答Curretly有沒有辦法讓路由信息。儘管你可以獲取參數。你的激活函數將被每個參數調用一個參數。
路徑問題很簡單,但仍然不能回答這個問題:如何在激活函數中獲取當前的URL和querystrings?我很想使用window.location,但我想認爲有一個更好的方法來完成這個使用框架。 –
我結束了使用window.location找到哈希。但是,查詢字符串的參數將在激活函數中傳遞(感謝Rob Eisenberg的澄清)。 –
更新了包含指向谷歌組的鏈接的答案。 – RainerAtSpirit