这是我为TinyMCE编写的代码
@model TinyEditorWithMVCApp.Models.Post
@{
ViewBag.Title = "AddPost";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Add new Post</h2>
<h2>Add new Post</h2>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>TintMCE App</title>
<script src="~/Scripts/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "modern",
plugins: "advlist,code,bbcode,hr,link,paste,save",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "center",
theme_advanced_statusbar_location: "bottom",
forced_root_block: false,
});
</script>
</head>
<body>
<div>
@using (Html.BeginForm("AddPost", "Home", FormMethod.Post))
{
<div>
@Html.TextBoxFor(model => model.AuthorName)
</div>
<div>
@Html.TextAreaFor(model => model.Body)
</div>
<div>
<input type="submit" value="Save Post" />
</div>
}
</div>
</body>
</html>
结果应该是这样的。在这里输入图片描述
而这是我在调试项目后得到的结果。请在此输入图片描述
我的代码有什么问题?
我从我的浏览器检查控制台,我得到这个错误 请在此输入图片描述
你没有分享你使用的TinyMCE的版本,但假设你使用的是TinyMCE v5.x,你配置中的几个选项是无效的。
最重要的是,你的配置中没有 modern
TinyMCE 5中的主题,所以这一行是无效的。
theme: "modern",
TinyMCE会自动使用它的默认主题,所以你根本不需要这一行--你可以直接删除它。 虽然你的错误信息很难阅读,但我相信你发布的错误是TinyMCE无法加载不存在的 modern
主题。
所有以 theme_advanced_
也不适用于TinyMCE 5--这些都是在TinyMCE 3.x中最后一次有效。