vue project, the route uses vue-router hash # mode. When sharing pages in Wechat, there is no problem with config configuration, and the backend returns normally. When you want to inject sharing information into the sharing page, it is as follows
created () {
this.title = window.location.href
this.content = window.location.href.split("-sharp")[0]
let url = window.location.href.split("-sharp")[0]+"-sharp"+window.location.href.split("-sharp")[1]
this.pin = url
let that = this
wx.ready(() => {
wx.onMenuShareTimeline({
title: "", //
link: url, // JS
imgUrl: "", //
success: function (res) {
//
that.$messagebox({
title: "success",
content: res
})
}
}),
wx.onMenuShareAppMessage({
title: "", //
desc: "", //
link: url, // JS
imgUrl: "", //
type: "", // ,musicvideolinklink
dataUrl: "", // typemusicvideo
success: function () {
//
that.$messagebox({
title: "success",
content: res
})
}
});
})
}
when sharing in moments and sharing with friends, The shared link was inserted by Wechat with a string as follows
the link that http://www.xxx.com/test/-sharp/share
shared with a friend: from=singlemessage&isappinstalled=0-sharp/share" rel= "nofollow noreferrer" > http://www.xxx. Com/test/?from.
the link after sharing to moments: from=timeline&isappinstalled=0-sharp/share" rel=" nofollow noreferrer "> http://www.xxx.com/test/?from.
is inserted before the-sharp account
it"s the same thing to share with each other on iOS and android. The shared page will open normally, but you can"t get it if you follow the parameters after the link. How to jump into the pit