The pits we stepped on together in those years (2) The difference in the data format transmitted by the real machine and the simulator about the uniapp development of the Dingding applet and some precautions

First of all, I wish you all a happy Youth Day, a happy May Day holiday, and a great life! Today, let’s share about the different data formats transmitted by the real machine and the emulator for the development of the DingTalk applet by uniapp, as well as some precautions.
I encountered a problem a few days ago. The DingTalk emulator can display data, but the real machine cannot display data. I have developed several small programs, but they are all developed on the small program editor. For the multi-platform use of a project, I use uniapp development. It is the first time to try it. My server is using .netwebapi, and the front end is uniapp (vue syntax). Here I first insert the request specification of uniapp, the request specification of Dingding. Please see the picture below:
Insert picture description here

Insert picture description here

My problem is mainly in the request header.
This is my initial request header is application/json method:
Insert picture description here
for POST method and header['content-type'] is application/json data, JSON serialization will be performed. Causes problems with the data format transmitted by my real machine and the simulator.

The following is the correct request header and the receiving method of the server data: In
Insert picture description here
Insert picture description here
this way, the format of the data transmitted by the real machine and the simulator is the same (the format of the request parameters is the same)

For data with POST method and header['content-type'] is application/x-www-form-urlencoded, the data will be converted to query string. This is the default request header, and most of them are compatible.

To sum up: You can use the following methods to troubleshoot problems encountered with real machine and simulator data display: 1 Is the requested address added to the secure domain name, 2. Look at the request and response issues (especially the data transmission format) Pay special attention)

Next, I will talk about a simple little detail. When developing DingTalk or Alipay applets in uniapp, the suffix of the referenced style should be changed to acss, otherwise it will not be recognized when uploading and packaging.
Insert picture description here
Today’s analysis ends here, if you have any exchanges, you can add my QQ 869849885!

Guess you like

Origin blog.csdn.net/qq_40200030/article/details/105923483