Jump and transfer of pit 91

Time:2020-1-18

When he was dying, he sat up and asked with a smile where bug came from?!

1. First it’s capital letters

Two days ago, a new version of “seven comments” v2.0.0 was released. As a result, you know, a program without bugs is not a good program, and a programmer who can’t write bugs is not a good programmer.

Well, it’s normal to have one or two bugs.

There is user feedback, received the message reply notice, but click in there is no content. How can there be bugs? You must have used the wrong method.

When I got home from work, I immediately opened the developer tool and found that, as expected, I couldn’t write bugs.

It’s a good hand to write bugs, and it’s not bad for me to find bugs. The final reason is that the parameters are not passed correctly.

 

A page
// a.wxml
B

// a.js
toB(e) {
  var i = e.currentTarget.dataset;
  wx.navigateTo({
    url: '/pages/b?testID=' + i.testID + '&openid=' + i.openid,
  })
  console.log(i)
}
B page
// b.js
onLoad: function (options) {
  this.setData({
    testID: options.testID,
    openid: options.openid
  })
}

The result is:

Obviously, openid gets the right parameters, which indicates that the gross problem in the receiving and delivery process is that the testid is wrong before delivery.

The console prints the dataset and finds that no testid has changed to testid.

What does this mean? It means he’s doing something. He’s doing me! Here, change testid to testid, and it will be passed correctly.

Data binding cannot be capitalized. Remember, brother die. (or you can bind in uppercase and get it in lowercase. Happy)

2、Even one? Dare to fuck me?

After changing the bug, I thought I could have a rest meeting, but in the middle of the night, someone came to me again: it failed to reply to the reader.

I tried, but I didn’t find what he said. Then he went back and said: refresh? Try twice more? Change the network? It’s not my problem

After a while, the elder brother said it was still not possible. Then the elder brother came with me to find bugs in the middle of the night. I was moved. I also sent a red envelope to thank him for finding bugs.

Finally, we found that the data was disconnected at a question mark. The front data was normal, and the back data was truncated. Take a closer look because the user has entered an English?」??????

Do a test:

 

A page
// a.wxml
toB
// a.js
toB(e) {
  var i = e.currentTarget.dataset;
  wx.navigateTo({
    url: '/pages/b?hello=' + i.hello,
  })
}
B page
// b.js
onLoad: function (options) {
  this.setData({
    hello: options.hello,
  })
}

The result is as follows in appdata:

As expected, it was the English question mark that caused the trouble. The skull hurt?I’m good at south south and south south.


3, pan he

If you find a problem, just dial him, but it’s not for the user’s fault. He knows when to input a 「?” Because adding parameters to jump path is also used?So this is supposed to be a mistake?“With parameters.

At last, I think of two ways. Here is for your reference. If there is a better way, please leave a message to discuss.

1. When you jump to the pagedataset The second is the key.

II. utilization replaceTurn? Into?

But there’s a problem with using replace(‘?’, ‘?’)It can only be converted once.

What if you input multiple English question marks? This possibility is not excluded, so it is not recommended to use replace(‘?’, ‘?’), regular expressions are recommended, that isreplace(/\?/g, “?“) To translate English question marks.

 

4, last

Nine seven of seven abdominal muscles has come back. It hasn’t been updated for some time. I’ve been busy writing small programs, mainly because I haven’t thought of a better excuse.

There are 101 days left in this year. I will try my best to climb up and update. Click below“Write a message”Discuss together. Sharing and discussion are better ways to learn. Shake up.

This article starts with the public number “I am nine seven years later”.