2016-03-07 30 views
0

引用Bootstrap-Colorpicker我正在通过ASP.NET MVC 6教程并习惯框架。我有要求将颜色选择器添加到我的某个视图中。由于IE5不支持HTML5类型的“颜色”,我无法使用它。如何在ASP Net 5查看

取而代之的是我认为我会在这里使用bootstrap-colorpicker插件:http://mjolnic.com/bootstrap-colorpicker/

我已经通过NPM安装了该软件包,但无法找到如何在View中引用它的方法。包是否应该在wwwroot\libs文件夹中安装文件?或者我需要手动复制这些文件并在@section Scripts中参考?

我也安装了它使用的NuGet PM它似乎References下,但我在同一条船上想知道如何引用它在实际View

+0

将'js'和'css'文件拖到您的视图中。 –

+0

从哪里来?我在'wwwroot'的任何地方都看不到这个文件。我的源文件有一个'node_modules'文件夹(包含colorpicker),但我无法看到在Visual Studio中如何访问它。 – jidl

+0

检查[这篇博客文章],希望它将会帮助你找到你安装的软件包。 – Michael

回答

0

用的NuGet PM安装程序创建以下文件夹结构:

/Content 
    /bootstrap-colorpicker 
     /css 
      /bootstrap-colorpicker.css 
     /img 
      /*.png 
/Scripts 
    /bootstrap-colorpicker.js 

所以,你必须以下行添加到BundleConfig:

bundles.Add(New ScriptBundle("~/bundles/colorscripts").Include(
    "~/Scripts/bootstrap-colorpicker.js") 
bundles.Add(New StyleBundle("~/Content/bootstrap-colorpicker/bootstrap-colorpicker/colorstyle").Include(
    "~/Content/bootstrap-colorpicker/css/bootstrap-colorpicker.css")) 

然后引用捆绑在Razor视图:

@section SiteCSS 
    @Styles.Render("~/Content/bootstrap-colorpicker/bootstrap-colorpicker/colorstyle") 
End Section 

@section Scripts 
    @Scripts.Render("~/bundles/colorscripts") 
End Section 

BTW:样式束的附加“bootstrap-colorpicker”文件夹是优化器所必需的。否则,你会得到一个404(请参阅here,herehere)。