problem description
in the react project, the configuration information of Wechat official account has been successfully configured in a component entry js file. When you click the button in the sub-components of this component, you can share to moments and other sharing functions. Button clicks can be monitored locally, but Wechat shares no response. What should I do? Did I write it wrong? Or how do you want to test it?
the environmental background of the problems and what methods you have tried
1. Wechat notarization account configuration information has been configured, prompting {"errMsg": "config:ok"}
2, react project, Wechat configuration information is placed in the component entry, Wechat sharing events are placed in the public sub-components
3, tested in Wechat on the phone and Wechat developer tools, click on non-response
4, local development, using IP address. The js security domain name of the test number is filled in with the local test address
5, and the post request method is encapsulated by myself
related codes
A.js
class A extends Component{
componentWillMount() {
let params = {...}
post("/wx/xxxx", params).then(data => {
window.wx.config({
debug: true, // ,apialertpclogpc
appId: ***, //
timestamp: ***, //
nonceStr: ***, //
signature: ***,//
jsApiList: *** // JS
});
})
}
render(){
return(
<div>
...
<Child />
</div>
)
}
}
:Child.js
class Child extends Component{
share = () => {
console.log("--share start--") //
window.wx.onMenuShareTimeline({ //
title: "",
link: "http://192.168.1.26:5002/activity/share", // JS
imgUrl: "",
success: function () {
alert("")
}
});
}
getElement() {
return (
<div>
...
<Button onClick={()=> this.share()}></Button> //
</div>
)
}
render(){
return (
<div>
...
{this.props.xxx ? this.getElement(): <B /> }
</div>
)
}
}
what result do you expect? What is the error message actually seen?
Interface prompt {"errMsg": "config:ok"}
console print:-- share start--
Gods, is my code wrong? Or is my test method wrong?
set up an official account for the first time. I don"t know if it is right or wrong, and I don"t know how to modify it. Please give me some advice. Thank you ~