天天看點

修改僞元素content

第一種方法:  利用 标簽的data-* 屬性和content:attr(data-*) 結合

CSS

.refresh-item-list {
  margin: 0 1rem 1rem;
  box-shadow: 0 0 4px 0 rgba(38, 49, 190, 0.2);
  border-radius: 8px;  &:before {
    content: attr(data-content-before);
    position: absolute;
    top: -30px;
  }
}      

HTML

 <div className="refresh-item-list" data-content-before="下拉重新整理">
     xxx      
const list = document.querySelector('.refresh-item-list');
list.attributes[1].value ='要修改的值';