多语言展示
当前在线:889今日阅读:46今日分享:45

vue添加class样式。

vue提供了一个动态添加class的v-bind:class(:class) 对象,可以使用:class进行clas动态的切换。案例中将通过使用:class设置 字体为红色。
方法/步骤
2

在html代码页面创建一个

同时添加id为app,并添加一段文本

3

引入vue.js文件。使用标签引入vue文件。

4

创建vue实例。新建一个

5

创建设置字体为红色的red样式。在标签后面创建一个<style>标签,然后设置字体为红色的red样式。代码:<style> .red{ color: red; } </style></p></div><div class="listcon"><span>6</span><p>使用:class添加red类样式。在<div>标签里面添加 :class='{red:true}'。</p></div><div class="listcon"><span>7</span><p>保存html代码后使用浏览器打开,即可看到字体已经变为了红色</p></div></div><div class="prev_next"> <div class="prev"> <span>上一篇:</span><a href="/dvegn.html">jquery判断是否有某个class</a> </div> <div class="next"> <span>下一篇:</span><a href="/dvegp.html">如何使用css类class选择符</a> </div> </div> </div> <div class="appleccmw content-right"> <div class="listmore">推荐信息</div> <div class="send_list"> <ul> <li><a href="/dvegi.html" title="vue怎么实现切换class类"><span>1</span><h3>vue怎么实现切换class类</h3></a></li> <li><a href="/dvego.html" title="vue添加class样式。"><span>2</span><h3>vue添加class样式。</h3></a></li> <li><a href="/bprql.html" title="荷花书签折纸怎么折"><span>3</span><h3>荷花书签折纸怎么折</h3></a></li> <li><a href="/bprqk.html" title="写小说如何写出虐的剧情"><span>4</span><h3>写小说如何写出虐的剧情</h3></a></li> <li><a href="/bprqj.html" title="有的新衣服会自带一小块布料蚂蚁庄园答案"><span>5</span><h3>有的新衣服会自带一小块布料蚂蚁庄园答案</h3></a></li> <li><a href="/bprqi.html" title="衣服领子松了怎么办呢?"><span>6</span><h3>衣服领子松了怎么办呢?</h3></a></li> <li><a href="/bprqh.html" title="洗保暖内衣最好的方法?"><span>7</span><h3>洗保暖内衣最好的方法?</h3></a></li> <li><a href="/bprqg.html" title="辨别衣服的质量好与差有什么方法?"><span>8</span><h3>辨别衣服的质量好与差有什么方法?</h3></a></li> <li><a href="/bprqf.html" title="宝宝哭闹存在的这几种情况你一定要知道"><span>9</span><h3>宝宝哭闹存在的这几种情况你一定要知道</h3></a></li> <li><a href="/bprqe.html" title="不同衣服的布料该如何清洗"><span>10</span><h3>不同衣服的布料该如何清洗</h3></a></li> <li><a href="/bprqd.html" title="棉麻衣物护理常识"><span>11</span><h3>棉麻衣物护理常识</h3></a></li> <li><a href="/bprqc.html" title="怎么让衣服变大"><span>12</span><h3>怎么让衣服变大</h3></a></li> <li><a href="/bprqb.html" title="T恤洗衣小常识,衣服要怎么洗?"><span>13</span><h3>T恤洗衣小常识,衣服要怎么洗?</h3></a></li> <li><a href="/bprqa.html" title="为什么纯棉连体工作服不需要熨烫整理?"><span>14</span><h3>为什么纯棉连体工作服不需要熨烫整理?</h3></a></li> <li><a href="/bprpz.html" title="租房怎么找房东个人房源"><span>15</span><h3>租房怎么找房东个人房源</h3></a></li> <li><a href="/bprpy.html" title="学习困难是如何诊断的?"><span>16</span><h3>学习困难是如何诊断的?</h3></a></li> <li><a href="/bprpx.html" title="怎样选购棉衣?棉衣选购指南"><span>17</span><h3>怎样选购棉衣?棉衣选购指南</h3></a></li> <li><a href="/bprpw.html" title="纯棉毛巾的特点及如何保养"><span>18</span><h3>纯棉毛巾的特点及如何保养</h3></a></li> <li><a href="/bprpv.html" title="什么面料的工作服可以干洗"><span>19</span><h3>什么面料的工作服可以干洗</h3></a></li> <li><a href="/bprpu.html" title="扎紧袋口后放入衣柜中,就成了现成的除湿剂。"><span>20</span><h3>扎紧袋口后放入衣柜中,就成了现成的除湿剂。</h3></a></li> <li><a href="/bprpt.html" title="夏季降温消暑的必备经验"><span>21</span><h3>夏季降温消暑的必备经验</h3></a></li> <li><a href="/bprps.html" title="新生儿护理十大禁忌 别说我没告诉你"><span>22</span><h3>新生儿护理十大禁忌 别说我没告诉你</h3></a></li> </ul> <div class="clear"></div> </div> </div> </div> <div class="clear"></div> <div class="onjfeeds"></div><span class="onj_live"></span><span class="childonj"></span><div class="onj_location"></div><span class="buddhaonj"></span><div class="branchesccmw footer_service"> <a href="/sitemap.html" target="_blank">网站地图</a> <a href="/sitemap.xml" target="_blank">XML</a> <a href="/sitemap.txt" target="_blank">TXT</a> <a href="/rss.xml" target="_blank">RSS</a> <a href="/privacy.html" target="_blank">隐私政策</a> <a href="/service.html" target="_blank">服务条款</a> <a href="/agreement.html" target="_blank">使用条款</a> <div class="flagccmw footer_copyright clogWalletccmw">Copyright ©1996-2026 www.onijiang.com Corporation, All Rights Reserved</div> </div> <script src="/static/index1js/jquery-3.5.1.min.js" rel="external nofollow"></script> <script src="/static/js/share.js" rel="external nofollow"></script> <script src="/static/js/tran.js" rel="external nofollow"></script> <script src="/static/js/langs.js" rel="external nofollow" ></script> <div class="onj_happy"></div><span class="containeronj"></span><div class="baronj" id="baronj"></div><div id="Family_seal_onj"></div><script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body> </html>