小编Suc*_*Man的帖子

为什么更新不适用于 vue.js?

我的代码是这样的:

updated() {
    console.log('test')
}, 
Run Code Online (Sandbox Code Playgroud)

演示和完整代码如下:https : //jsfiddle.net/50wL7mdz/58492/

我在控制台上查看,console.log('test') 的结果没有显示

如果我使用安装,它的工作原理

为什么如果我使用更新,它不起作用?

我该如何解决问题?

vue.js vue-component vuejs2

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

如何在迁移 Laravel 上使用更改表添加字段?

我使用 Laravel 5.3

我的迁移是这样的:

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('api_token')->nullable();
            $table->string('email',100)->unique();
            $table->string('password')->nullable();
            $table->string('avatar',100)->nullable();
            $table->string('full_name',100)->nullable();
            $table->date('birth_date')->nullable();
            $table->smallInteger('gender')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }
    public function down()
    {
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
        Schema::dropIfExists('users');
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
    }     
}
Run Code Online (Sandbox Code Playgroud)

我想添加这样的新字段:

$table->string('mobile_number',20)->nullable();
Run Code Online (Sandbox Code Playgroud)

但我不想将它添加到架构中。我想使用alter table

在我的临时服务器和实时服务器上设置了自动迁移

所以如果我使用alter table,它会自动迁移。所以如果代码合并到 development 或 master 数据库中的表会自动添加 mobile_number 字段

如果我添加架构,它不会自动迁移

如何使用alter table添加字段?

migration laravel laravel-5 laravel-5.3

3
推荐指数
2
解决办法
9370
查看次数

如何在邮件通知 Laravel 上添加条件?

我使用 Laravel 5.3

我的通知 laravel 是这样的:

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Notifications\Messages\BroadcastMessage; 
class GuestRegistered extends Notification implements ShouldBroadcast, ShouldQueue
{
    use Queueable;
    private $data;
    public function __construct($data)
    {
        $this->data = $data;
    }
    public function via($notifiable)
    {
        return ['mail'];
    }
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->subject('test')
                    ->greeting('Hi')
                    ->line('Thanks')
                    ->line('Your password : '.$this->data)
                    ->action('Start Shopping', url('/'));
    }
}
Run Code Online (Sandbox Code Playgroud)

我想在 toMail 方法中添加条件

所以如果$this->data不存在->line('Your password : '.$this->data)则不显示或不执行

我该怎么做?

email notifications laravel laravel-5 laravel-5.3

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

如何在 bootstrap vue 上制作按钮减号和加号?

我从这里得到教程:https : //bootstrap-vue.js.org/docs/components/form-input

我想做这样的:

在此处输入图片说明

我尝试这样:

<template>
    ...
        <b-col class="pr-0 custom-control-inline">
            <b-btn variant="warning btn-sm mr-1 mt-1 mb-1"><i class="fa fa-minus-circle"></i></b-btn>
            <b-form-input type="number" class="col-md-3" v-model="quantity"></b-form-input>
            <b-btn variant="info btn-sm ml-1 mt-1 mb-1"><i class="fa fa-plus-circle"></i></b-btn>
        </b-col>
    ...
</template>
<script>
    export default {
        data () {
            return {
                quantity: null
            }
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

结果是这样的:

在此处输入图片说明

如何使按钮加号和减号起作用?

所以如果点击按钮加号,数量会增加

css twitter-bootstrap bootstrap-4 vue-component vuejs2

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

选择自动完成vuetify时如何获取对象?

我的代码是这样的:

<div id="app">
  <v-app id="inspire">
    <div>
      <v-autocomplete
        label="Clubs"
        :items="clubs"
        item-text="name"
        v-model="selectedClub"
      ></v-autocomplete>
    </div>
    <v-btn text color="primary" @click="submit">OK</v-btn>
  </v-app>
</div> 
Run Code Online (Sandbox Code Playgroud)

演示是这样的: https //codepen.io/positivethinking639/pen/GRRNzVE?&editable=true&editors=101

如果调用 submit 方法,则显示选定的名称。例如:亩

你可以在console.log中看到

我想要如果调用提交方法,它会在数组中显示对象。所以我得到了 id 和 name

我该怎么做?

vuetify.js

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

如何使用 jquery 验证以像素为单位添加验证维度?

我的 jquery 验证是这样的:

store: {
    rules: {
        banner: {
            required: true
        }
    },
    messages: {
        banner: 'The banner must be filled',
    },
    errorElement: 'span',
    errorPlacement: errorPlacement,
    highlight: highlight,
    unhighlight: unhighlight
},
Run Code Online (Sandbox Code Playgroud)

如果用户不上传尺寸为 1170 x 300 像素的横幅,则会出现如下消息:

请上传一张 1170 x 300 像素尺寸的图片

我该怎么做?

javascript jquery jquery-validate

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

如何在vue组件中显示所需的html 5?

我的vue组件是这样的:

<template>
    <div>
        ...
        <form class="form-horizontal" id="form-profile">
            ...
            <input type="number" class="form-control" required>
            ...
            <button type="submit" class="btn btn-primary" @click="submit">Submit</button>
            ...
        </form>
        ...
    </div>
</template>
<script>
    export default {
        ...
        methods: {
            submit(e) {
                e.preventDefault()
                if (this.checkForm()) {
                    // do ajax here
                }
            },
            checkForm() {
                let field = true
                $('#form-profile :required').each(function(i) {
                    if(this.checkValidity() == false) 
                        field = false
                })
                return field
            },
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我使用必需的html5进行验证

e.preventDefault()用来防止页面重定向.因为我想使用ajax

我的问题是必要的验证html5如果没有填写则不显示.也许是因为我使用e.preventDefault()

如何显示所需的html5?

javascript jquery vue.js vue-component vuejs2

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

如何在集合laravel中添加数字?

如果我dd($items),结果是这样的:

在此处输入图片说明

我想为每个数组添加数字

所以第一个数组,存在值为 1 的键号

第二个数组,存在值为 2 的键号

等等

我尝试这样:

$items->map(function ($item) {
    $item['number'] = 1;
    return $item;
});
Run Code Online (Sandbox Code Playgroud)

数量不增加。我很困惑做计数器

我怎么解决这个问题?

php collections counter laravel laravel-5.6

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

如何在laravel中要求作曲家自动加载器?

我想安装guzzle https://github.com/guzzle/guzzle

我阅读了参考资料,但我对此部分感到困惑:

在此输入图像描述

从该教程,请求要求composer autoloader.所以似乎需要添加require 'vendor/autoload.php'; 我添加脚本的位置?

我使用laravel 5.6

autoloader laravel guzzle laravel-5 laravel-5.6

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

如何在模式Vue中使用窗口打印?

我的Vue组件是这样的:

<template>
    ...
    <b-modal id="modalInvoice" size="lg"  title="Invoice">
        <Invoice/>
        <div slot="modal-footer" class="w-100"> 
            <b-btn size="sm" class="float-right" variant="warning" @click="show=false">
                <i class="fa fa-print"></i> Print
            </b-btn>
        </div>
    </b-modal>

    ...
        <b-btn variant="warning" class="btn-square mt-2" v-b-modal.modalInvoice @click="checkout()"><i class="fa fa-credit-card-alt"></i>Checkout</b-btn>
    ...
</template>
<script>
    ...
    export default {
        ...
        methods: {
            print() {
                window.print()
            }
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

如果我单击“打印”按钮,它将起作用。但是它将显示整个网站。我只想单击打印按钮,它仅显示模态的内容

我该怎么做?

javascript bootstrap-modal vue.js vue-component vuejs2

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