天天看点

bootstrap-markdown编辑器引入

MarkdownAsset.php

<?php

namespace app\assets; use yii\web\AssetBundle; class MarkdownAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ 'bootstrap-markdown/css/bootstrap-markdown.min.css' ]; public $js = [ 'bootstrap-markdown/js/bootstrap-markdown.js', 'bootstrap-markdown/locale/bootstrap-markdown.zh.js', ]; public $depends = [ 'yii\web\YiiAsset', 'yii\bootstrap\BootstrapAsset', ]; } 
           

_from.php

<?php

use yii\helpers\Html; use yii\widgets\ActiveForm; use app\assets\MarkdownAsset; /* @var $this yii\web\View */ /* @var $model app\models\Article */ /* @var $form yii\widgets\ActiveForm */ MarkdownAsset::register($this); ?> <form> <input name="title" type="text" placeholder="Title?" /> <textarea name="content" data-provide="markdown" rows="10"></textarea> <label class="checkbox"> <input name="publish" type="checkbox"> Publish </label> <hr/> <button type="submit" class="btn">Submit</button> </form> 
           

点了预览之后无效,如下图

bootstrap-markdown编辑器引入

不知道是不是因为引入资源出了问题,希望各位前辈能指导下

解决办法

不能预览的原因是缺少markdown.js 和to-markdown.js

其实在bootstrap-markdown 的文档中有说,在网页最底端,不注意看文档就容易忽视这个,不过我是在stackoverflow上找到的解决办法,希望对以后遇到此问题的同学能有帮助。

转载于:https://www.cnblogs.com/grimm/p/5983968.html

继续阅读