目录
1,vue 自动编译
npm run watch
2,vue 编译报错如下
Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
<template>!!!!****不允许有俩个DIV节点</template>
3,laravel创建测试数据
task表中对应字段body
\App\Task::forceCreate(['body'=>'123']);
4,laravel中使用pusher
需npm install pusher-js laravel-echo
5,vue中的表单
action 可以用
<form @submit.prevent="addTask" method="post">
methods:{
addTask(){
axios.post('/tasks', {'body': this.newTask});
this.tasks.push(this.newTask);
this.newTask=''
}
}
数据绑定用(不是v-mode)v-model
6,laravel migrate
字段内容过长
Schema::defaultStringLength(191);
建表前判断存在与否
Schema::dropIfExists(table);
7,laravel 主外键及factory生成测试数据
migrate :
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('label')->nullable();
$table->timestamps();
});
Schema::create('permissions_role', function (Blueprint $table) {
$table->increments('id');
$table->integer('permission_id');
$table->integer('role_id');
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->timestamps();
$table->primary(['permission_id', 'role_id',]);
});
factory :
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});
$factory->define(App\Post::class, function (Faker\Generator $faker) {
return [
'title' => $faker->sentence,
'body' => $faker->paragraph,
'user_id' => factory(App\User::class)->create()->id,
];
});