小程序:

<template>
	<view>
		<web-view v-if="webUrl" :src="webUrl"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				webUrl: "",
				token: "",
			};
		},
		onLoad() {
			this.token = uni.getStorageSync('userInfo').token
			this.webUrl = "https://dd.ycsmes.com/h5?wx=1&token=" + this.token
			console.log(this.webUrl);
		},
	};
</script>

H5

app.vue中动态引入微信JSSDK,直接在页面中引入会出现wx.miniProgram为undefined (坑了我好久)

		onLaunch(e) {
			var script = document.createElement('script')
			script.src = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js"
			script.type = 'text/javascript';
			document.body.appendChild(script)
		},

在需要进行返回操作的页面

 

wx.miniProgram.navigateBack()

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐