MarkdownAsset.php
<?php
namespace appassets;
use yiiwebAssetBundle;
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 = [
'yiiwebYiiAsset',
'yiiootstrapBootstrapAsset',
];
}
_from.php
<?php
use yiihelpersHtml;
use yiiwidgetsActiveForm;
use appassetsMarkdownAsset;
/* @var $this yiiwebView */
/* @var $model appmodelsArticle */
/* @var $form yiiwidgetsActiveForm */
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>
点了预览之后无效,如下图
不知道是不是因为引入资源出了问题,希望各位前辈能指导下
解决办法
不能预览的原因是缺少markdown.js 和to-markdown.js
其实在bootstrap-markdown 的文档中有说,在网页最底端,不注意看文档就容易忽视这个,不过我是在stackoverflow上找到的解决办法,希望对以后遇到此问题的同学能有帮助。
