自定义Aurelia以使用.cshtml [英] Customizing Aurelia to use .cshtml
问题描述
我发现了一篇非常有帮助的文章,展示了如何在aurelia中使用Razor部分(cshtml).但是,我无法运行代码并从RobEisenberg评论中学到
I found a very helpful article showing how to use Razor partials (cshtml) with aurelia. However, I could not get the code to run and learned from RobEisenberg comment that
ConventionalViewStrategy.convertModuleIdToViewUrl
已被弃用.他评论说:您想使用ViewLocator服务."我关注了gitHUb项目,但看不到它与我对MVC5和Razor Partials的使用直接相关.所以我很困惑.
had been deprecated. He commented "You want to use the ViewLocator service." I followed the gitHUb project and could not see that it was directly relevant to my using with MVC5 and Razor Partials. So I am confused.
这是我希望可以进行调整的示例main.js文件,以便将aurelia路由到Home/Index/Index.cshtml而不是index.html
This is the example main.js file that I was hoping I could tweak in order to route aurelia to the Home/Index/Index.cshtml instead of index.html
import {LogManager} from "aurelia-framework";
import {ConsoleAppender} from "aurelia-logging-console";
import {ConventionalViewStrategy} from "aurelia-framework";
LogManager.addAppender(new ConsoleAppender());
LogManager.setLevel(LogManager.logLevel.debug);
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
ConventionalViewStrategy.convertModuleIdToViewUrl = function(moduleId){
var moduleName = moduleId.replace("Scripts/", "");
return `./Templates/${moduleName}`;
}
aurelia.start().then(a => a.setRoot("./Scripts/index", document.body));
}
有人可以告诉我如何在MVC5项目中设置aurelia以使用.cshtml而不是.html模板吗?我正在使用Typescript和VS2015
Can anyone tell me how to set up aurelia in an MVC5 project to use .cshtml instead of .html templates? I am using Typescript and VS2015
推荐答案
我刚刚成功地遵循了 查看全文