擬解決問題:
給a標簽添加disabled屬性后,效果置灰不可點擊,但鼠標放上去是箭頭
。
期望:鼠標放上去顯示紅色禁用符號
。
<a :disabled="true">刪除</a>
效果:
在控制臺查看元素:
發(fā)現(xiàn)給a標簽disabled屬性添加上了鼠標禁用樣式
cursor:not-allowed和鼠標禁用事件
pointer-event:none,但禁用樣式不生效。
樣式不生效的原因是:這兩者同時使用時,元素永遠不會成為鼠標事件的target。
解決方案:在a標簽外層包裹一個span,在span上添加樣式
。a標簽的鼠標禁用事件依舊生效。保證了樣式和事件同時生效。文章來源:http://www.zghlxwxcb.cn/news/detail-849998.html
<span style="cursor: not-allowed">
<a :disabled="true">刪除</a>
</span>
效果:文章來源地址http://www.zghlxwxcb.cn/news/detail-849998.html
到了這里,關于a標簽添加disabled屬性后,沒有鼠標禁用的紅色樣式(cursor:not-allowed不生效)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!