Page [components/listCard/listCard] error: TypeError: Cannot read property 'name' of undefined Problem solved

Page [components/listCard/listCard] error: TypeError: Cannot read property 'name' of undefined

This problem is very pit

Because I started my lunch break after completing some functions of the applet in the morning

After my lunch break, I plan to continue developing small programs

At this point, WeChat developer tools asked me to update

After I updated it, I kept jumping out this error

I found a method on the Internet, and the methods from Baidu are the same, basically useless

The following method may be useful for components written by yourself

one of the solutions

But after I changed it, other UI components reported errors, and these components were packaged and built through node_modules

So I definitely can't change what's inside him

And it's too silly to change all the things in it, it doesn't conform to our style as programmers

So I simply deleted the components I wrote and tried it.

Sure enough, it is also an error report of other UI components.

So I found a small program I wrote before to try it out.

I found that it could run, so I looked at the details
insert image description here
and found that the only difference in it was debugging the basic library

And I didn't change anything else, just updated the WeChat developer tools

So I changed the debugging base library and tried it, and found that this is the problem

The close-up is here, hoping that students who encounter the same problem can have a reference.

Now that this is written, I will write about another bug I encountered before.

Apple phone date compatibility issues

New Date(time) of Apple mobile phone

The parameter passed in the format of 'YYYY-MM-DD' is not supported

That is to say, the date format in the form of YYYY-MM-DD cannot be parsed

It's weird, I don't know why

But it supports date format in the form of YYYY/MM/DD

Timestamps are also supported

If the data format returned by the backend is 2022-07-19T06:33:50.000000Z

similar to this format

We need to extract his date and time for parsing

Here I wrote a wheel for formatting time

I also hope to help everyone

// 格式化时间
const formatDate = function (time, format = "yyyy-MM-DD") {
    
    
  if (time[time.length - 1] === "Z") {
    
    
    let timeArr = time.split("T");
    timeArr[1] = timeArr[1].split(".")[0];
    time = timeArr[0].replaceAll("-", "/") + " " + timeArr[1];
  }

  let t = new Date(time);
  let tf = function (i) {
    
    
    return (i < 10 ? "0" : "") + i;
  };
  return format.replace(/yyyy|YYYY|MM|dd|DD|HH|hh|mm|ss|SS/g, function (a) {
    
    
    switch (a) {
    
    
      case "yyyy":
        return tf(t.getFullYear());
        break;
      case "YYYY":
        return tf(t.getFullYear());
        break;
      case "MM":
        return tf(t.getMonth() + 1);
        break;
      case "dd":
        return tf(t.getDate());
        break;
      case "DD":
        return tf(t.getDate());
        break;
      case "hh":
        return tf(t.getHours());
        break;
      case "HH":
        return tf(t.getHours());
        break;
      case "mm":
        return tf(t.getMinutes());
        break;
      case "ss":
        return tf(t.getSeconds());
        break;
      case "SS":
        return tf(t.getSeconds());
        break;
    }
  });
};

I hope it can be helpful to you. If possible, I hope to take a look at my blog on the way.
New blog
Previous blog

Guess you like

Origin blog.csdn.net/Vixcity/article/details/128548169