您需要从字符串中提取数字,并将其传递给Date
constructor:
var x = [{ "id": 1, "start": "/Date(1238540400000)/"}, { "id": 2, "start": "/Date(1238626800000)/"}];var myDate = new Date(x[0].start.match(/d+/)[0] * 1);这些部分是:
x[0].start - get the string from the JSONx[0].start.match(/d+/)[0] - extract the numeric partx[0].start.match(/d+/)[0] * 1 - convert it to a numeric typenew Date(x[0].start.match(/d+/)[0] * 1)) - Create a date object



