小编Aru*_*ath的帖子

使用 sortBy 方法排序在下划线中不起作用

我正在尝试使用下划线 sortBy 方法对对象数组进行排序,json 如下

[
   {
      "styleId": 91,
      "styleName": "Style Label",
      "dataSourceId": 1,
      "dataSourceName": null,
      "stationeryId": 1,
      "stationeryName": null,
      "styleType": 1,
      "styleTypeName": "Labels",
      "isActive": true,
      "isPlainPaper": true,
      "isSystemMaintained": false,
      "isPublished": true,
      "designerUrl": null,
      "sourceStyleId": 0,
      "rowIndicatorCode": 2,
      "isDefault": null,
      "hasElement": true,
      "styleDesign": null,
      "createdBy": "real",
      "createdDate": 1494217733790,
      "modifiedBy": "superuser",
      "modifiedDate": 1494388952450,
      "rowVersion": "AAAAAAIC8ls="
   },
   {
      "styleId": 69,
      "styleName": "irtest",
      "dataSourceId": 1,
      "dataSourceName": null,
      "stationeryId": 16,
      "stationeryName": null,
      "styleType": 1,
      "styleTypeName": "Labels",
      "isActive": true,
      "isPlainPaper": false,
      "isSystemMaintained": false,
      "isPublished": true,
      "designerUrl": …
Run Code Online (Sandbox Code Playgroud)

javascript sorting underscore.js

3
推荐指数
1
解决办法
676
查看次数

使用正则表达式开始和结束点

您好我试图在Javascript中使用正则表达式来验证输入,我的要求是我在字符串中最多只能有一个点('.')并且不能在开头和结尾.我得到了一个解决方案

/^[^\.].*[^\.]$/;
Run Code Online (Sandbox Code Playgroud)

但问题是输入"x"被认为是无效的 有效输入,如"x","xx","xx.x","x.xx",如".x"和"x"之类的无效.

javascript regex

1
推荐指数
1
解决办法
70
查看次数

标签 统计

javascript ×2

regex ×1

sorting ×1

underscore.js ×1