码迷,mamicode.com
首页 > 其他好文 > 详细

bootstrap和elementUI真的会冲突

时间:2017-12-29 12:25:32      阅读:516      评论:0      收藏:0      [点我收藏+]

标签:let   影响   type   cli   同事   preview   model   rip   tab   

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

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

bootstrap和elementUI真的会冲突

标签:let   影响   type   cli   同事   preview   model   rip   tab   

原文地址:https://www.cnblogs.com/XHappyness/p/8142993.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!