我有两个嵌套在App Component上的CarouselComponent和BannerComponent组件。我想在CarouselComponent中获取BannerComponent中的元素以进行滚动功能。
代码在这里;
-App.js
....
<App>
<BannerComponent />
<CarouselComponent />
</App>
....
Run Code Online (Sandbox Code Playgroud)
--- BannerComponent.js
...
return(
<div className="banner-div" id="banner-div">
</div>
);
...
Run Code Online (Sandbox Code Playgroud)
--- CarouselComponent.js
...
scrollTo() {
document.getElementById("banner-div") // This doesn't work
}
...
return(
<a onClick={this.scrollTo}></a>
);
Run Code Online (Sandbox Code Playgroud)
我想知道在所有情况下如何在React js中获取元素。
我试图将数据保存在模型函数中。使用模型的save()函数时,出现如下错误。
照射\数据库\ QueryException:SQLSTATE [42S22]:柱未找到:1054未知列'的updated_at'在'字段列表'(SQL:插入到
account_types(name,updated_at,created_at)的值(设备厂,2019年8月5日五时33分57秒, 2019-08-05 05:33:57))在文件F:\ HTML&
我已删除表coz中的created_at和updated_at列,我不需要它。我想知道在Laravel中使用模型save()函数时如何禁用created_at和update_at数据保存。
<?php
namespace pshub;
use Illuminate\Database\Eloquent\Model;
class AccountType extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
// Create Type Function
public function createType($type) {
$existence = $this->where('name', $type)->get();
if (sizeof($existence) > 0) {
return $this->where('name', $type);
} else {
$this->name = $type;
$this->save();
return $this->id;
}
}
}
Run Code Online (Sandbox Code Playgroud)