uni-app share applet page

The applet page of uni-app is not shareable by default. When you click the button in the upper right corner of the page to share, it will prompt: "The current page cannot be forwarded / the current page cannot be shared"

configuration

Open the manifest.json file of the project, and under "Share" of the "App Module Configuration" item, check "WeChat Sharing":

Enable the share and forward button in the code

<script>
	export default {
		created() {
			//#ifdef MP-WEIXIN
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			//#endif
		},
		data() {
			return {
				title:'标题',
				thumb:'https://img.demo.com/static/images/1.jpg'
			}
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: this.title,
				imageUrl: this.thumb,
			}
		},
		onShareTimeline(res) { //分享到朋友圈
			return {
				title: this.title,
				imageUrl: this.thumb,
			}
		},
		methods: {
		}
	}
</script>

Open the Mini Program page again, and you will find that it is ready to share.

 

Guess you like

Origin blog.csdn.net/watson2017/article/details/130238223