vue动态添加当前事件下的class

2020-04-30 08:59:44
html部分
<div class="star">
  <span v-for="(item,index) in 5" @click="clickStar($event)"></span>
</div>
说明:遍历span 5次,得到5组span,$event为目标事件

js部分
clickStar($event){
  $event.currentTarget.className='active';//console.log($event.currentTarget);
}

说明:当点击目标事件的时候,目标事件下的目标元素,增加class,这样就实现了动态添加class。
(currentTarget:
目标元素)


  • 2020-12-21 09:42:42

    iframe.contentWindow 操作iframe

    注:iframe.contentWindow这里,返回的是iframe的window对象,所以后面可以接着调用document方法,再接着调用getElementByTagName。那么就可以对iframe里面的元素进行操作了。

  • 2020-12-21 14:00:19

    iframe + postMessage跨域通信

    在实际项目开发中可能会碰到在 a.com 页面中嵌套 b.com 页面,这时第一反应是使用 iframe,但是产品又提出在 a.com 中操作,b.com 中进行显示,或者相反。

  • 2020-12-22 12:02:41

    ios开发优秀的开源框架,demo集合

    期待大家和我们一起共同维护,同时也期望大家随时能提出宝贵的意见(直接提交issues即可)。请广大网友只按照目录结构(即使目录结构有问题)添加三方库,并提交pull request。目录问题大家提出issues后楼主会及时更改的。