我以前创建过用户表.现在我创建了一个新的迁移来在我的模式中创建一个新的books表.当我尝试运行命令时
php artisan migrate
Run Code Online (Sandbox Code Playgroud)
表明:
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre
ady exists (SQL: create table `users` (`id` int unsigned not null auto_incr
ement primary key, `username` varchar(255) not null, `email` varchar(255) n
ot null, `password` varchar(255) not null, `created_at` timestamp default 0
not null, `updated_at` timestamp default 0 not null) default character set
utf8 collate utf8_unicode_ci)
Run Code Online (Sandbox Code Playgroud)
这是我的新迁移表:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBooksTable extends Migration {
public function up()
{
Schema::create('books', function(Blueprint …Run Code Online (Sandbox Code Playgroud) margin-left: 10px;和之间有什么区别
position: relative; left: 10px;?
它似乎产生了相同的结果
我想要定位两个span和一个按钮,如下所示:
SPAN1
跨距2
按键
但是,使用我当前的代码,它们看起来像这样:
span1 span2按钮
body {
text-align:center;
}
span#printHere {
color:black;
font-size:30px;
position:relative;
}
span#triesLeft{
align='centre';
font-size:30px;
position:relative;
}
Run Code Online (Sandbox Code Playgroud) 我正在学习React.js,我看到super关键字在构造函数中使用了很多.
据我所知,super允许子类访问该this关键字.但是,我找不到更多的解释.
super(),神奇地让我的班级访问this?super关键字绑定this到类的上下文?super()?我一直在阅读React的快速入门文档;
无论是将组件声明为函数还是类,它都不能修改自己的道具
这是一个"纯"函数,因为它不会尝试更改其输入,并且始终为相同的输入返回相同的结果:
function sum(a, b) {
return a + b;
}
Run Code Online (Sandbox Code Playgroud)
这是一个"不纯"的功能,因为它改变了自己的输入:https: //codesandbox.io/s/9z38xv4x7r
function SayHi(props) {
props.name = "Jim"; // TypeError Cannot assign to read only property 'name' of object '#<Object>'
return <h1>Hi {props.name}!</h1>;
}
Run Code Online (Sandbox Code Playgroud)
为什么React道具是只读的?
我有一个返回宠物及其主人的 API 端点。
Django 模型示例:
class Owner(models.Model):
name = models.CharField(max_length=200)
class Pet(models.Model):
owner = models.ForeignKey(Owner, on_delete=models.CASCADE)
name = models.CharField(max_length=200)
Run Code Online (Sandbox Code Playgroud)
我已经配置了我的 API 来返回这样的 JSON 数据:
[
{
"id": 2,
"name": "Scotch",
"owner": {
"id": 2,
"name": "Ben"
}
},
{
"id": 3,
"name": "Fluffy",
"owner": {
"id": 1,
"name": "Fred"
}
},
{
"id": 1,
"name": "Spot",
"owner": {
"id": 1,
"name": "Fred"
}
}
]
Run Code Online (Sandbox Code Playgroud)
DRF 序列化器示例:
class OwnerSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Owner …Run Code Online (Sandbox Code Playgroud) 我的表格:
<form id="main-contact-form" name="contact-form" ata-request="onSend" data-request-success="alert('Message Sent')">
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到一个表格发布; 我在哪里放这个文件?我编辑哪个文件使其将表单数据字段发送到我的电子邮件?我已经设置了后端邮件设置:
function onSend()
{
// Collect input
$name = post('name');
$email = post('email');
$message = post('message');
// Submit form
$to = System\Models\MailSettings::get('sender_email');
$params = compact('name','email');
Mail::sendTo($to, 'temp.website::mail.newrequest', $params);
return true;
}
Run Code Online (Sandbox Code Playgroud) 我正在遵循https://material-ui.com/components/autocomplete/ 中的各种示例来创建自定义自动完成。我正在尝试使用该renderInput属性来使用自定义输入组件。我发现的所有示例都使用该TextField组件,但我想使用常规input组件。
问题是,这些选项永远不会显示。我已经在这里创造一个示范(互换renderInput使用renderInputWORKING,看看工作版本):
https://codesandbox.io/s/epic-johnson-oxy7b?file=/src/App.tsx
使用以下代码renderInput:
const renderInput = (params: AutocompleteRenderInputParams) => {
console.log(params);
const { InputLabelProps, inputProps, InputProps } = params;
return (
<div>
<label {...InputLabelProps}>foo</label>
<input {...InputProps} {...inputProps} />
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
如何将<input />组件用于renderInputprop on <Autocomplete />?
我有一个要重叠的图片列表,因此它们看起来与此类似:
我的代码:
.avatar img {
border-radius: 50%;
position: relative;
left: -5px;
z-index: 1;
}Run Code Online (Sandbox Code Playgroud)
<div class="avatars">
<span class="avatar">
<img src="https://lorempixel.com/50/50/" width="25" height="25"/>
</span>
<span class="avatar">
<img src="https://lorempixel.com/50/50/" width="25" height="25"/>
</span>
<span class="avatar">
<img src="https://lorempixel.com/50/50/" width="25" height="25"/>
</span>
<span class="avatar">
<img src="https://lorempixel.com/50/50/" width="25" height="25"/>
</span>
<!-- Variable amount more avatars -->
</div>
<p>4 People</p>Run Code Online (Sandbox Code Playgroud)
但显然,我需要一个递增的left值,以及z-index化身img数量的递减。当然,我可以使用@for指令来执行此操作,但事实是,有大量的头像img。我当时在看length()函数,但是它不能像我打算的那样使用。
另一个想法是设置一个固定的div宽度,并适合其中的图像,但这有其自身的问题(如果有5张图像或20张图像,如何控制宽度)。我还可以在其他地方按需要合并图像,而不使用任何CSS。
我有一个包含不同扩展名的文件列表.淘汰者我想筛选出只有那些扩展.bam,.bai,.vcf和更多一些.有没有办法使用带有多个参数的endswith函数而不是多次重复它?
所以代替:
for name in list:
if name.endswith('.bam') or name.endswith('.bai') or name.endswith('.bai'):
# do stuff
Run Code Online (Sandbox Code Playgroud)
就像是:
for name in list:
if name.endswith(*['.bai', '.bam', '.vcf']):
# do stuff
Run Code Online (Sandbox Code Playgroud) css ×3
reactjs ×3
html ×2
laravel ×2
php ×2
ajax ×1
autocomplete ×1
django ×1
ecmascript-6 ×1
javascript ×1
kwargs ×1
material-ui ×1
mysql ×1
octobercms ×1
overlap ×1
overlay ×1
properties ×1
python ×1
sass ×1
sendmail ×1
string ×1