Vue.js学习笔记(三):隐藏a标签鼠标悬浮状态下浏览器左下角出现的链接地址

前言

当a标签悬浮时浏览器左下角会出现链接地址,为了隐藏链接地址,除了使用用点击事件代替以外,我们还可以一次性解决页面所有a标签悬浮出现链接的问题。

mounted() {
	this.deleteMsg();
},
methods: {
	deleteMsg() {
					$("body").on('mouseover', 'a', function(e) {
						let $link = $(this)
						let href = $link.attr('href') || $link.data("href");
						// console.log($link, href)
						$link.off('click.chrome');
						$link.on('click.chrome', function() {
								window.location.href = href;
							})
							.attr('data-href', href)
							.css({
								cursor: 'pointer'
							})
							.removeAttr('href');
					})
				}
}

最后附上点击事件处理方法


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>如何隐藏鼠标放在A标签上时浏览器左下角显示的跳转界面地址</title>
<body>
 
<a href="javascript:;" οnclick="redirect($(this))" val="http://www.baidu.com">A标签跳转</a>
 
</body>
<script charset="utf-8" src="jquery-min.js"></script>
<script>
    /**
     * 跳转
     */
    function redirect(options) {
        var url = options.attr('val');
        window.location.href = url;
    }
</script>
</html>

以上仅供学习参考

你可能感兴趣的:(Vue.js,vue.js,html5)