WeChat's built-in browser prompts to jump to an external browser

Source code + material

technology stack

uniapp + Vue2

Effect

Please add a picture description

accomplish

H5 does not prompt, WeChat built-in browser prompts

  • JS window.navigator.userAgent decision
<view class="top-tip" v-if="isWeichatBrowser">
	<text class="op65">点击右上角按钮,然后在弹出的菜单中,点击在浏览器中打开,即可安装</text>
	<image src="./分享箭头.png" mode="scaleToFill"></image>
</view>
data() {
    
    
	return {
    
    
		isWeichatBrowser: false,
	}
},
onLoad() {
    
    
	let result = /MicroMessenger/i.test(window.navigator.userAgent)
	if (result) {
    
    
		this.isWeichatBrowser = true
	}
}

Animated popup for top tip

  • CSS animation animation
.top-tip {
    
    
	height: 80px;
	background-color: rgb(52, 52, 52);
	color: #fff;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
	/*CSS 动画 animation*/
	animation: loading 1s linear;
	position: relative;
	font-size: 12px;
	padding:0 60px 0 20px;
	image{
    
    
		position: absolute;
		right: 0;
		top:10%;
		width: 50px;
		height: 40px;
		z-index: 99;
	}
}
@keyframes loading {
    
    
	0% {
    
    
		height: 0;
	}
	
	25% {
    
    
		height: 16px;
	}
	
	50% {
    
    
		height: 32px;
	}
	
	75% {
    
    
		height: 48px;
	}
	
	100% {
    
    
		height: 80px;
	}
}

Guess you like

Origin blog.csdn.net/m0_61486963/article/details/129344275