【问题标题】:Summernote in Asp.Net MVCAsp.Net MVC 中的 Summernote
【发布时间】:2016-08-15 02:04:19
【问题描述】:

我尝试按照教程here 在我的 Asp.Net MVC 项目中实现 Summernote 所见即所得编辑器。

我以为我遇到了与 this guy 相同的问题并实施了建议,但仍然无济于事。

我还根据here 修改了我的 web.config 文件以尝试修复字形图标问题,但也无济于事。

如果有人能告诉我我做错了什么,将不胜感激。

在文本区看到文本区,按钮图标不渲染

根据 Chrome 调试器渲染的 HTML

.cshtml

<div class="form-group">
            @Html.LabelFor(model => model.Recipe.Instructions, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextAreaFor(model => model.Recipe.Instructions, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Recipe.Instructions, "", new { @class = "text-danger" })
            </div>
        </div>

捆绑

 public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles) {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/font-awesome.css",
                      "~/Content/site.css",
                      "~/Content/globalStyles.css"));

            bundles.Add(new StyleBundle("~/Content/summernote").Include(
                "~/Content/summernote/summernote.css"
                ));

            bundles.Add(new ScriptBundle("~/bundles/summernote").Include(
               "~/Content/summernote/summernote.js"
               ));
        }
    }

文件结构

镀铬错误

【问题讨论】:

  • 我对summernote一无所知,但@Html.TextAreaFor(model =&gt; model.Recipe.Instructions, new { htmlAttributes = new { @class = "form-control"} })看起来很不对劲。也许你的意思是@Html.TextAreaFor(model =&gt; model.Recipe.Instructions, htmlAttributes: new { @class = "form-control"})
  • 并且不要将代码发布为图像,这绝对不会帮助任何人进行搜索(并迫使我手动输入所有内容)
  • @PaulAbbot new { htmlAttributes = new { @class = "form-control"} }) 由 vs2015 生成。我尝试了旧方法,但没有任何区别。现在更改我的问题以用代码替换屏幕截图

标签: asp.net-mvc font-awesome summernote


【解决方案1】:

我修改了我的 cshtml 文件中的脚本部分,以像这样包含 css 包

@section Scripts {
    @Scripts.Render(
        "~/bundles/jqueryval",
        "~/bundles/summernote",
        "~/Scripts/recipeCreate.js",
        "~/Scripts/wysiwyg.js");
    @Styles.Render(
        "~/Content/summernote"
    );
}

【讨论】:

    【解决方案2】:

    我已经更改了 bundle.config

    bundles.Add(new StyleBundle("~/Content/summernote/summernote.css").Include( "~/Content/summernote/summernote.css" ));

    并在 _Layout.cshtml 中使用此捆绑包进行了更改

    `@Styles.Render("~/Content/summernote/summernote.css")`
    

    【讨论】:

      猜你喜欢
      • 2015-06-14
      • 2014-10-29
      • 2015-11-19
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 2015-04-13
      • 2011-08-19
      • 2014-08-22
      相关资源
      最近更新 更多