中华美食网,思想汇报2012年5月,热奇艺
这里用文字举例,图片切换的原理也是一样的
大概思路是:用两个class相同的span分别是切换前后的文字,class相同主要是为了变换前后的文字位置相同。然后用click事件控制它们的显隐。
代码如下:
html:
<span class="response" v-show="!showcommentinput" @click="showcommentinput = !showcommentinput">回复</span> <span class="response" v-show="showcommentinput" @click="showcommentinput = !showcommentinput">回复</span>
js:
data(){ return { showcommentinput = false, } }
css:
.response { font-size:14px; color: #3e3e3e; &:hover{ font-weight: bold; } &+.response { font-weight: bold; }
以上这篇vue实现点击后文字变色切换方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
VUE+elementui组件在table-cell单元格中绘制微型echarts图
Vue通过getAction的finally来最大程度避免影响主数据呈现问题
vue 路由懒加载中给 Webpack Chunks 命名的方法
网友评论