前两天,做了一个支持markdown的功能: http://www.cnblogs.com/XHappyness/p/8097756.html

后面发现预览效果某些标签需要bootstrap的支持才能显出相关的样式,于是乎 npm bootstrap;并在此页面的.ts文件中  import 'bootstrap/dist/css/bootstrap.min.css',本以为只在改页面引入并不会影响全局样式,然并卵!!

解决办法:将预览地方的div换成iframe

.vue

              <div class="marked">
<el-tabs v-model="tastDtailType" @tab-click="changeTab" class="markdown-tabs">
<el-tab-pane label="Write" name="write">
<el-input type="textarea" placeholder="请输入备注" v-model="task.description" :autosize="{minRows: 2, maxRows:30}" class="none-border"></el-input>
</el-tab-pane>
<el-tab-pane label="Preview" name="preview">
<iframe id="tast-dtail-preview" runat="server" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
<!-- <div id="tast-dtail-preview"></div> -->
</el-tab-pane>
</el-tabs>
</div>

.css

/* markdown格式 */
.marked {
min-height: 120px;
padding:10px;
border-radius: 4px;
border: 1px solid #bfcbd9;
&:hover {
border-color: #8391a5!important;
}
& #tast-dtail-preview {
margin-left: 7px;
}
}

.ts

  //任务详情markd是预览还是书写
changeTab(tastDtailType) {
this.tastDtailType = tastDtailType.name;
if (tastDtailType.name === 'preview' && this.task.description != '') {
let tastDtailPreview = Marked(this.task.description);
let iframe = document.querySelector('#tast-dtail-preview') as HTMLIFrameElement;
iframe.contentDocument.body.innerHTML = '<head><link href="http://crowdsourcing.gridsumdissector.com/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"></head>' +
tastDtailPreview;
}
}

方法也是笨拙而巧妙,感谢同事帮忙挖坟。。。。

新坑:不滚动的话,内容不能全部显示,目前还没研究怎么是iframe自动高度,于是乎还是滚吧....

//任务详情markd是预览还是书写
changeTab(tastDtailType) {
this.tastDtailType = tastDtailType.name;
if (tastDtailType.name === 'preview') {
let tastDtailPreview = Marked(this.task.description);
let iframe = document.querySelector('#tast-dtail-preview') as HTMLIFrameElement;
iframe.contentDocument.body.innerHTML = '<head><link href="http://crowdsourcing.gridsumdissector.com/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"></head>' + tastDtailPreview;
let height = $('.none-border').height(); //.none-border是左侧书写部分的
      let width = $('.none-border').width(); 
iframe.style.height = height + 'px'; iframe.style.width = width + 'px';
}
}

bootstrap和elementUI真的会冲突的更多相关文章

  1. bootstrap modal与select2使用冲突解决

    今天发现项目使用bootstrap modal 与 jquery select2 结合时发现select2不起作用,点击select框不显示选项,查阅资料后发现是因为modal层遮挡了select2的 ...

  2. 时间插件datepicker(jQuery-UI,bootstrap)和jquery-steps的冲突解决。。。

    日期插件初始化:  $('.prelease_time').flatpickr(); let contentSteps = $("#content_form").steps({ h ...

  3. 解决bootstrap row span设置border换行的问题

    Hadoop方面的毕业设计告一段落了,趁这几天空闲时间认真学习一下之前常使用但是却没用好的Bootstrap. 本文记录Bootstrap框架使用栅格系统时,遇到row内的span设置border换行 ...

  4. BootStrap 4正式版发布(原文翻译)

    原文链接:http://blog.getbootstrap.com/2018/01/18/bootstrap-4/ 关于Bootstrap 什么是Bootstrap Bootstrap,来自 Twit ...

  5. 打造 Vue.js 可复用组件

    Vue.js 是一套构建用户界面的渐进式框架.我们可以使用简单的 API 来实现响应式的数据绑定和组合的视图组件. 从维护视图到维护数据,Vue.js 让我们快速地开发应用.但随着业务代码日益庞大,组 ...

  6. Vue 全家桶 + Electron 开发的一个跨三端的应用

    代码地址如下:http://www.demodashi.com/demo/11738.html GitHub Repo:vue-objccn Follow: halfrost · GitHub 利用 ...

  7. vue中如何编写可复用的组件?

    原文地址 Vue.js 是一套构建用户界面的渐进式框架.我们可以使用简单的 API 来实现响应式的数据绑定和组合的视图组件. 从维护视图到维护数据,Vue.js 让我们快速地开发应用.但随着业务代码日 ...

  8. [转载]SVN-主干/分支

    一个大项目在开发中可能会拆分成几个小项目,分别分去,同时共通的部分再由人做,做完后再统一合并.同时,在开发中,共通的部分修改后,其它人要保持同步. 这种情况反应到SVN的分支/合并功能上,再贴切不过了 ...

  9. Kendo UI for ASP.NET MVC 的一些使用经验(转)

    转自 http://blog.csdn.net/dj2008/article/details/45313805 最近的项目里用到了Kendo UI.这货很好很强大,但可惜官方文档组织的并不是很好,有很 ...

随机推荐

  1. Django快速开发投票系统

    使用Django搭建简单的投票系统:这个是官网的教程:https://docs.djangoproject.com/en/2.0/intro/tutorial01/ 在Run manage.py Ta ...

  2. cors(Cross-origin resource sharing)跨域资源共享

    阮一峰老师的文章(http://www.ruanyifeng.com/blog/2016/04/cors.html)跨域资源共享详解和https://developer.mozilla.org/zh- ...

  3. 使用webBrowser进行C#和JS通讯

    .前台调用后台: 在webBrowser使用过程中为了C#和js通讯,webBrowser必须设置ObjectForScripting的属性,它是一个object,这个object可以提供给webBr ...

  4. css文本截字,超出文本省略号显示

    一.单行文本截字 p { text-overflow: ellipsis;/*显示省略号代替裁剪的文本*/ white-space: nowrap;/*空白处理方式 不换行*/ overflow: h ...

  5. windows和Ubuntu下安装mongodb

    windows 下载 mongodb官网下载压缩版安装包:下载地址:https://www.mongodb.com/download-center/community 注意选择版本(目前windows ...

  6. Awakening Your Senses【唤醒你的感觉官能】

    Awakening Your Senses Give youself a test. Which way is the wind blowing? How many kinds of wildflow ...

  7. Rmarkdown:输出pdf设置

    输出pdf需要安装Ctex --- title: "first markdown" author: "name" date: "`r format(S ...

  8. SIMD数据并行(三)——图形处理单元(GPU)

    在计算机体系中,数据并行有两种实现路径:MIMD(Multiple Instruction Multiple Data,多指令流多数据流)和SIMD(Single Instruction Multip ...

  9. WPF中InkCanvas(墨水面板)用法

    原文:WPF中InkCanvas(墨水面板)用法   WPF中InkCanvas(墨水面板)用法                                                    ...

  10. struts2官方 中文教程 系列十三:利用通配符选择方法

    介绍 在本教程中,我们将介绍如何在struts.xml中配置action节点以达到仅使用一个action节点将几个不同的url关联到特定action类的特定方法.这样做的目的是减少struts.xml ...