当前位置: 首页 > news >正文

bootstrap和elementUI真的会冲突

前两天,做了一个支持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';
}
}

 

转载于:https://www.cnblogs.com/XHappyness/p/8142993.html

相关文章:

  • LeetCode:26. Remove Duplicates from Sorted Array(Easy)
  • jvm 内存分配
  • 从Storm和Spark 学习流式实时分布式计算的设计
  • Nginx + Tomcat + HTTPS 配置原来不需要在 Tomcat 上启用 SSL 支持
  • 应用多级缓存模式支撑海量读服务
  • iOS 兼容多个有crash 收集机制的SDK
  • 37.3. HQL
  • 详细解析漏洞4个boom
  • HSRP、VRRP、ACL
  • 407. 加一
  • NoClassDefFoundError
  • 压缩打包介绍 gzip压缩工具 bzip2压缩工具
  • 数组注意事项
  • Git与GitHub学习笔记(八)git如何同时同步提交到码云和GitHub上
  • 阿里人工智能实验室?对,这个神秘机构即将登场
  • [ 一起学React系列 -- 8 ] React中的文件上传
  • conda常用的命令
  • JSDuck 与 AngularJS 融合技巧
  • ReactNative开发常用的三方模块
  • storm drpc实例
  • UMLCHINA 首席专家潘加宇鼎力推荐
  • 阿里云购买磁盘后挂载
  • 爬虫模拟登陆 SegmentFault
  • 容器化应用: 在阿里云搭建多节点 Openshift 集群
  • 深入浅出Node.js
  • 使用common-codec进行md5加密
  • 适配mpvue平台的的微信小程序日历组件mpvue-calendar
  • 我看到的前端
  • 写代码的正确姿势
  • 以太坊客户端Geth命令参数详解
  • 鱼骨图 - 如何绘制?
  • gunicorn工作原理
  • linux 淘宝开源监控工具tsar
  • 继 XDL 之后,阿里妈妈开源大规模分布式图表征学习框架 Euler ...
  • ​sqlite3 --- SQLite 数据库 DB-API 2.0 接口模块​
  • (Redis使用系列) Springboot 实现Redis消息的订阅与分布 四
  • (附源码)spring boot火车票售卖系统 毕业设计 211004
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (每日持续更新)jdk api之StringBufferInputStream基础、应用、实战
  • (十三)Flask之特殊装饰器详解
  • (四)模仿学习-完成后台管理页面查询
  • (学习日记)2024.01.19
  • (原創) 物件導向與老子思想 (OO)
  • (转)http-server应用
  • (转)Oracle 9i 数据库设计指引全集(1)
  • .bat批处理(十):从路径字符串中截取盘符、文件名、后缀名等信息
  • .NET 解决重复提交问题
  • .net6+aspose.words导出word并转pdf
  • .Net环境下的缓存技术介绍
  • :not(:first-child)和:not(:last-child)的用法
  • [2017][note]基于空间交叉相位调制的两个连续波在few layer铋Bi中的全光switch——
  • [Android Pro] Notification的使用
  • [AutoSar]BSW_Memory_Stack_004 创建一个简单NV block并调试
  • [BZOJ] 2044: 三维导弹拦截
  • [CQOI 2011]动态逆序对