小编Mel*_*hia的帖子

在 ionic 2/3 中禁用离子搜索栏

我想在 ionic 2/3 中禁用 ion-searchbar 以便只显示搜索栏但我们不能输入任何内容。我添加了,"disabled = true"但这不起作用。

你能提出一些建议吗?

javascript ionic-framework ionic2 ionic3 angular

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

如何使用离子日期时间来显示未来年份

我有一个离子日期时间。它正在发挥作用,但只能持续到今年及往后。

我想要的是从今年开始并继续下去。是否可以?

<ion-item>
<ion-label>Event Date</ion-label>
<ion-datetime displayFormat="D MMM, YY" pickerFormat="DD MMM YYYY" [(ngModel)]="eventDate">
</ion-datetime>
Run Code Online (Sandbox Code Playgroud)

javascript ionic-framework ionic2 ionic3 angular

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

在javascript中更改线条颜色

我想在单击按钮时更改第2行的背景颜色,但唯一改变的是整个背景.

function changeColor() {
  document.body.style.backgroundColor = "black";
  document.getElementByID("Div2").style.backgroundColor = "black";

}
Run Code Online (Sandbox Code Playgroud)
<div id="Div2">

  <div>Line 1</div>
  <div2 class="line">Line 2</div2>
  <div>Line 3</div>
  <button onclick="changeColor()">Change color</button>
Run Code Online (Sandbox Code Playgroud)

html javascript css

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

从 Git 中提取最新的标签版本

我想提取 Git 存储库的最新版本数。这是我到目前为止所做的:

#--- Checking out latest tag
printf "%bChecking out tag...%b\n" "${YELLOW}" "${GRAY}"
LATEST_TAG=$(git describe --tags)
printf "\nChecking out tag %b${LATEST_TAG}%b\n" "${YELLOW}" "${GRAY}"
git checkout -b V${LATEST_TAG%-*} ${LATEST_TAG}
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果git describe --tags返回这样的东西,1.0.0-39-gf8f8306我最终会创建一个分支V1.0.0-39

我想要的是创建一个名为V1.0.0.

bash git-bash

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

使用匿名/箭头函数回调分配速记

我有这个代码示例:

 before('get all users', h => {
    return getAllUsers().then(function (users) {
      return h.supply.users = users;
    });
  });
Run Code Online (Sandbox Code Playgroud)

我正在寻找一些速记,这是我能做的最好的吗?

 before('get all users', h => {
    return getAllUsers().then(v => (h.supply.users = v));
 });
Run Code Online (Sandbox Code Playgroud)

我在想,也许我们可以使用一些替代的分配技巧.

javascript node.js arrow-functions

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

如何按两个字段对数组进行排序(包括日期)

我有一个对象数组,我想先按日期排序,然后按其数值排序.

let arr = [  
  {date: 2018-06-19 12:05:43.232Z, value: 3},
  {date: 2018-06-20 12:05:43.232Z, value: 4},  
  {date: 2018-06-18 12:05:43.232Z, value: 2},  
  {date: 2018-06-20 12:05:43.232Z, value: 4}, 
  {date: 2018-06-19 12:05:43.232Z, value: 5},     
  {date: 2018-06-18 12:05:43.232Z, value: 5},  
  {date: 2018-06-20 12:05:43.232Z, value: 5},  
  {date: 2018-06-19 12:05:43.232Z, value: 4},  
]
Run Code Online (Sandbox Code Playgroud)

我想按日期和值对每个索引进行排序,结果如下:

let arr = [
  {date: 2018-06-18 12:05:43.232Z, value: 2},
  {date: 2018-06-18 12:05:43.232Z, value: 5},

  {date: 2018-06-19 12:05:43.232Z, value: 3},
  {date: 2018-06-19 12:05:43.232Z, value: 4},
  {date: 2018-06-19 12:05:43.232Z, value: 5}, 

  {date: 2018-06-20 12:05:43.232Z, value: …
Run Code Online (Sandbox Code Playgroud)

javascript sorting

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

当我运行 npm run start 时出现此错误

当我运行时npm run start,出现以下错误:

错误守望者 --no-pretty get-sockname 返回退出代码 = 1,信号 = 空,标准错误 = 2018-01-13T17:08:24,417: [0x7fff97db03c0] 计算 sockname: 未能创建 /usr/local/var/ run/watchman/11reed-state: 没有那个文件或目录

我让它运行良好,但我在捆绑 index.js 文件时出现错误,所以我卸载了 watchman 并重新安装,现在我遇到了这个错误。

javascript node.js reactjs watchman react-native

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

收集"@ schematics/angular/migrations/migration-collection.json"无法解析

我正在尝试将项目的角度版本更新为V6.但是我收到以下错误:

$ ng update @angular/cli
Run Code Online (Sandbox Code Playgroud)

收集"@ schematics/angular/migrations/migration-collection.json"无法解析.

的package.json:

"dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26",
    "@angular/cdk": "5.0.0-rc.3",
    "@angular/flex-layout": "^2.0.0-beta.12",
    "@angular/material": "5.0.0-rc.3",
    "angular2-json-schema-form": "^0.7.0-alpha.1",
    "jsoneditor": "^5.14.0"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.5",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.5",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": …
Run Code Online (Sandbox Code Playgroud)

npm angular angular5 angular6

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

如何在javascript中使用CryptoJS

我使用CryptoJS而不是nodejscrypto模块,因为我只使用本机JavaScript,但有些代码不能工作:

function aesEncrypt(text, secKey) {
  const _text = text
  const lv = new Buffer('0102030405060708', 'binary')
  const _secKey = new Buffer(secKey, 'binary')
  const cipher = crypto.createCipheriv('AES-128-CBC', _secKey, lv)
  let encrypted = cipher.update(_text, 'utf8', 'base64')
  encrypted += cipher.final('base64')
  return encrypted
}
Run Code Online (Sandbox Code Playgroud)

那么我应该如何修改这些代码呢?

javascript node.js cryptojs

-2
推荐指数
2
解决办法
2万
查看次数