[英]Aurelia: History must implement activate()
I'm new to Aurelia, trying to implement some 'simple' dynamic routing with an id. 我是Aurelia的新手,尝试使用id实现一些“简单”的动态路由。
config.map([
{ route: 'questions/:id', . . .}
]);
I receive a runtime error which indicates I'm missing an activate() method. 我收到一个运行时错误,表明我缺少一个activate()方法。
aurelia-history.js:4 Uncaught (in promise) Error: History must implement activate().
at mi (aurelia-history.js:4)
at History.activate (aurelia-history.js:13)
at AppRouter.activate (aurelia-router.js:1743)
at aurelia-router.js:1722
I get that there is an activate() missing and it's dropping through to the prototype and throwing this error, I just can't figure out where to add the activate(). 我得知有一个activate()丢失,它正在下降到原型并抛出此错误,我只是无法弄清楚在哪里添加activate()。 I have it in my module, but should I somehow have one in my App class or this history object?
我在我的模块中有它,但我应该在我的App类或这个历史对象中有一个吗?
Thanks 谢谢
-John -约翰
Ok, for the benefit of other strugglers I tried to retrace my steps and piece together how I solved my problem - the challenge was I changed many variables. 好吧,为了其他斗士的利益,我试图回溯我的步骤并拼凑我如何解决我的问题 - 挑战是我改变了很多变数。 But I believe I was able to re-create my error and I broke my application in the same way as before.
但我相信我能够重新创建我的错误,并以与以前相同的方式破坏了我的应用程序。 The error may have started appearing when I upgraded my aurelia-router version from 1.2.1 to 1.6.2.
当我将aurelia-router版本从1.2.1升级到1.6.2时,错误可能已经开始出现。
This was my old package.json: 这是我的旧package.json:
{
"name": "ClientWeb",
"private": true,
"version": "0.0.0",
"devDependencies": {
"@types/webpack-env": "^1.13.0",
"aspnet-webpack": "^2.0.1",
"aurelia-bootstrapper": "^2.0.1",
"aurelia-fetch-client": "^1.0.1",
"aurelia-framework": "^1.1.0",
"aurelia-loader-webpack": "^2.0.0",
"aurelia-pal": "^1.3.0",
"aurelia-router": "^1.2.1",
"aurelia-webpack-plugin": "^2.0.0-rc.2",
"bootstrap": "^3.3.7",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.11.1",
"html-loader": "^0.4.5",
"isomorphic-fetch": "^2.2.1",
"jquery": "^3.2.1",
"json-loader": "^0.5.4",
"style-loader": "^0.16.1",
"ts-loader": "^2.0.3",
"typescript": "^2.2.2",
"url-loader": "^0.5.8",
"webpack": "^2.3.3",
"webpack-hot-middleware": "^2.18.0"
},
"dependencies": {
"@types/vis": "^4.21.7",
"vis": "^4.21.0"
}
}
At the time I was upgrading several libraries to the latest versions, but I tried reverting back to this original package.json and just updated the aurelia-router version - it generates the original error. 当时我正在将几个库升级到最新版本,但我尝试恢复到原来的package.json并刚刚更新了aurelia-router版本 - 它会生成原始错误。
Hope this helps someone. 希望这有助于某人。
-John -约翰
The reason you have this issue is because you didn't include aurelia-history-browser
in your plugins via: aurelia.use.history()
or aurelia.use.standardConfiguration()
. 你遇到这个问题的原因是因为你没有在你的插件中包含
aurelia-history-browser
: aurelia.use.history()
或aurelia.use.standardConfiguration()
。
The aurelia-history-browser
module implements the aurelia-history
abstract class History
, which is a wrapper around native History
of browser. aurelia-history-browser
模块实现了aurelia-history
抽象类History
,它是浏览器本机History
的包装器。 The abstract class History
basically throw an error with the method name when you call it, like the error you saw. 当您调用它时,抽象类
History
基本上会抛出方法名称的错误,就像您看到的错误一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.