当前位置: 移动技术网 > IT编程>脚本编程>vue.js > Vue实现点击后文字变色切换方法

Vue实现点击后文字变色切换方法

2018年02月17日  | 移动技术网IT编程  | 我要评论

中华美食网,思想汇报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实现点击后文字变色切换方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网