{{table_data}}
当前位置:   article > 正文

Vue的v-html样式无效问题_v-html table样式

v-html table样式

## 例如我在vue中添加了如下的v-html:

样式无效代码:

<table class="table"  v-html="table_data"   width="100%">
	 {{table_data}}
</table>
  
  <script>
  export default {
   data(){        
    return{
		    table_data:" <div class=\"tb_nodata\">测试 </div>"
 		   }
    }
    }
   </script>

    <style scoped>
      .tb_nodata{
	   font-size: 20px;
	   color: #0c08fc;
} 
    </style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

正确代码:

  <table class="table"  v-html="table_data"   width="100%">
	    {{table_data}}
  </table>
  
  <script>
  export default {
   data(){        
    return{
		    table_data:" <div class=\"tb_nodata\">测试 </div>"
 		   }
    }
    }
   </script>

    <style scoped>
      .table >>>.tb_nodata{
	   font-size: 20px;
	   color: #0c08fc;
} 
    </style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

在这里插入图片描述
格式为: .table >>>.tb_nodata{ 。。。},就可以生效了

其他外部组件引入,都要使用 “>>> “’这种语法。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/328693
推荐阅读
相关标签
  

闽ICP备14008679号