小编NuO*_*One的帖子

如何访问异步等待返回对象中的属性

为什么我无法使用.异步等待返回对象访问对象属性?我知道我可以访问如下属性。

let val1 = await call(3);
let val2 = await call(4);
Run Code Online (Sandbox Code Playgroud)

但我很感兴趣这是否可以做到

let v = await call(3).val + await call(4).val;
Run Code Online (Sandbox Code Playgroud)

let val1 = await call(3);
let val2 = await call(4);
Run Code Online (Sandbox Code Playgroud)

javascript async-await ecmascript-6

5
推荐指数
2
解决办法
2472
查看次数

如何使用内联javascript if语句将样式设置为表行

如果其中一个变量值为1,我想将背景颜色设置为灰色,否则行背景颜色将为白色

但事情是当变量值为1时,则添加了行但不添加了内容.如果变量值为0,则所有操作都按预期工作

我试过以下代码:

function insertRow(value){
  $('#invoiceTable').append(
    value === 1 ? '<tr style="background-color:	#ccc8cb">' : '<tr>'+
      '<td> category </td>' +
      '<td> material </td>' +
      '<td> ups </td>' +
    '</tr>'
  );
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<table id="invoiceTable" class="table table-bordered table-hover" >
  <thead>
      <tr>
          <th>Category</th>
          <th>Material</th>
          <th>ups</th>
      </tr>
  </thead>
  <tbody>
  </tbody>
</table>
 
<input type=button value='insert ash row' onclick='insertRow(1)'/>
 
<input type=button value='insert white row' onclick='insertRow(0)'/>
Run Code Online (Sandbox Code Playgroud)

请指出我做错了什么.

html javascript jquery

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

为什么我不能将 isset() 与 laravel $request-&gt;input('key') 一起使用

这两个片段是相同的

1)

if(isset($request->input('optionId'))){
  ....
  ....
  ....
  // statements will go here 
}
Run Code Online (Sandbox Code Playgroud)

2)

$optionId = $request->input('optionId');

if(isset($optionId)){
  ....
  ....
  ....
  // statements will go here 
}
Run Code Online (Sandbox Code Playgroud)

第一次尝试时,IDE 提示存在语法错误。当我保存它并运行解释器时说

“不能对表达式的结果使用 isset()(您可以使用“null !== expression”代替)”

但第二个执行得很好。

我的问题是当它分配给 $optionId 时它是一样的,对吗?为什么它在第二次尝试中运行而不是在第一次尝试中运行......有什么区别?

php post get laravel laravel-5

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

如何获取DB insert laravel的反馈

我的数据库插入查询如下

DB::table('job_details')->insert([
    'job_id'        => $jobId,
    'item_id'       => $itemId,
    'type_id'       => $typeId,
    'qty'           => $qnty,
    'laminating'    => $laminating,
    'mat_id'        => $matId,
    'rates'         => $rates,
    'sqft'          => $sqft,
    'ups'           => $ups,
    'master_qty'    => $masterQnty
]);
Run Code Online (Sandbox Code Playgroud)

如果查询成功或失败,我想获取状态。

php laravel laravel-5

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

如何在 C 中使用空的 main() 方法运行函数?

这种方法适用于C++,但不适用于C

它给了我这个错误 initializer element is not constant

#include <stdio.h>

int n = printf("Hello World");

int main() {}
Run Code Online (Sandbox Code Playgroud)

如何hello world使用空main函数打印?

我只需要将此C++代码转换为C

#include <iostream>
using namespace std;

int n = printf("Hello World");

int main() {}
Run Code Online (Sandbox Code Playgroud)

或这个

#include <iostream>
using namespace std;

int fun()
{
    cout << "Hello World";
    return 1;
}

int x = fun();

int main() {}
Run Code Online (Sandbox Code Playgroud)

或者这个 C++ 代码

#include <iostream>
using namespace std;

int fun()
{
    cout << "Hello …
Run Code Online (Sandbox Code Playgroud)

c c++ program-entry-point

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