SPA single page application authorization problem

In the project, I will develop a single page application (SPA) under wechat. The angular4 used for the front-end technology selection is the route configured according to the official document. Then I called the back-end interface in the root component of AppComponent to obtain wechat authorization, and called the wechat scan function in one component. When I clicked the button, Nani didn’t respond and the back-end interface didn’t report any errors. At this time, I went to the console of wechat developer tools to check whether the jsSDK of wechat was successfully authorized. Angular1 works the same way, but angular4 has a problem and wants to scold wechat. Angular1 uses hash routing and Angular4 does not use hash routing by default. Check the Angular4 article to use hash routing:

// Use hash routing
export const routing = RouterModule.forRoot(routes, {'useHash':true});
Copy the code

Ha ha as expected to solve the problem.

The wechat public account invokes the sharing function

I found that I called the sharing function of wechat and the shared address was the address of the current page. Since the hash route was used, I found that others could not access the page when I shared it. It was found that wechat removed all the things after #, and finally I found that one was added before #. That solves the problem.