如何在Orchard cms视图中包括样式表和js文件 [英] How to include style sheets and js files inthe view of Orchard cms
本文介绍了如何在Orchard cms视图中包括样式表和js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Orchard cms视图中包含样式表和js文件
无法加载资源:服务器响应状态为404(找不到)
How to include style sheets and js files inthe view of Orchard cms, Failed to load resource: the server responded with a status of 404 (Not Found)
推荐答案
-
在主题或模块中创建ResourceManifest.cs文件。
Create a ResourceManifest.cs file in your Theme or Module.
using Orchard.UI.Resources;
namespace MyNameSpace {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineStyle("MyScriptName").SetUrl("~/Modules/MyModule/Scripts/scripts.js");
manifest.DefineScript("MyStyleName").SetUrl("~/Themes/MyTheme/Styles/site.css");
}
}
}
b $ b
在你看来,包括这样的脚本和样式:
In your view, include the script and style like this:
@{
Style.Require("MyStyleName");
}
@using(Script.Foot()) {
Script.Require("MyScriptName");
}
您也可以使用Script.Head()将.js include < head>
标记。
You can also use Script.Head() to put the .js include in the <head>
tag.
这篇关于如何在Orchard cms视图中包括样式表和js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文