小编121*_*21c的帖子

Vue.js:服务器端应用程序的全局基 URL

在我正在开发的一个小型 Vue 应用程序中,有这样的代码:

this.axios.post('https://localhost:8000/api/auth/login',.......)

https://localhost:8000部署到服务器后,需求会发生变化,因为应用程序的服务器端将托管在不同的 IP 地址/端口。我想定义类似 a 的东西BASE_URL,可以从配置文件中读取或类似的东西,这意味着上面的代码将更改为类似的东西:

this.axios.post(`${BASE_URL}/api/auth/login`)

在 Vue.js 中执行此操作的最佳方法是什么?最初,baseUrl听起来很有希望,但这似乎不是我所需要的。

vue.js

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

"存储过程指定了太多参数"SQLServer

我已经构建了一个存储过程:

CREATE PROCEDURE dbo.sp_orders_by_dates 
    @start_date datetime,
    @end_date datetime
AS
    SELECT
      order_id, 
      orders.customer_id, 
      customers.name,
      shippers.name,
      shipped_date
    FROM orders 
    INNER JOIN customers ON orders.customer_id = customers.customer_id
    INNER JOIN shippers ON orders.shipper_id = shippers.shipper_id
    WHERE shipped_date BETWEEN @start_date AND @end_date
Run Code Online (Sandbox Code Playgroud)

当我使用以下方法执行程序时:

EXECUTE sp_customer_city 'January 1, 2003', 'June 30, 2003'
Run Code Online (Sandbox Code Playgroud)

我收到:

Msg 8144, Level 16, State 2, Procedure sp_customer_city, Line 0
Procedure or function sp_customer_city has too many arguments specified.
Run Code Online (Sandbox Code Playgroud)

我没有正确指定此过程可以采用两个参数吗?

sql sql-server stored-procedures sql-server-2012

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

保存后,Laravel模型ID为null(ID递增)

我有一个保存方法,我在那里进行验证,创建模型并保存.稍后在save方法中,我尝试访问模型的ID,它是NULL.

架构:

public function up()
{
    Schema::create('posts', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->string('body');
        //and other fields that aren't important right now
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

保存方法:

public function savePost(Request $request) {

    $this->validate($request, [
        //some validation happens here
    ]);

    $post = new Post();
    $title = $request->input('title');
    $body = $request->input('body');

    $post->title = $title;
    $post->body = $body;

    $post->save();

    //I later try to access the $post->id here and it's still NULL.
    var_dump($post->id);//NULL
}
Run Code Online (Sandbox Code Playgroud)

在MySQL中,ID被设置(只是一个自动递增的无符号整数) - 看起来它在savePost方法完成后被设置.

我认为在$post->save()完成后,模型的ID将被设置 - 但似乎并非如此.如何从我所用的相同方法访问模型的ID save()?或者我在某个地方犯了错误?

Laravel …

php mysql eloquent laravel-5

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

有没有更好的方法来包含 npm 安装的 CSS 文件?

我在我正在开发的 Vue 项目中使用 Quill WYSIWYG 编辑器。

我已经通过安装了鹅毛笔npm install quill@1.3.6。文件安装到node_modules/quill/.

当导入 JavaScript 时,我import Quill from 'quill'在需要它的组件中执行此操作,但为了包含 CSS,我在 Vue 组件中有一个部分,如下所示:

<style scoped>
    @import '../node_modules/quill/dist/quill.snow.css'
</style>
Run Code Online (Sandbox Code Playgroud)

这对我来说效果很好 - 但我不确定这是包含这些文件的最佳方法/是否有更好的方法。有没有更好的办法?我不确定通过node_modules目录访问它们是否是执行此操作的“专业”方法,或者这种方法是否存在任何问题

css dependencies quill vue.js

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

Stripe CLI:试用期结束时测试操作

我希望能够在本地测试用户试用期结束时是否采取了正确的操作。

我设置了 Stripe CLI,并开始监听:

stripe listen --forward-to http://localhost:8000/api/stripe-webhook
Run Code Online (Sandbox Code Playgroud)

当审判结束时,该customer.subscription.updated事件就会发生。

我使用 Stripe CLI 触发此事件:

stripe trigger customer.subscription.updated
Run Code Online (Sandbox Code Playgroud)

在我的服务器端,我可以看到它payload['data']['previous_attributes']包含一个带有foo = null. 当试验结束时,我们应该包含previous_attributes以下内容:{ "status": "trialing"...

我想知道是否可以使用 Stripe CLI 来触发一个模拟用户试用结束的事件(或者甚至只是将 设定为previous_attributes试用结束时在实时环境中发生的类似值的一种方法)?如果可以做到这一点,那么在本地测试当试验结束时会发生适当的操作而不需要推送到类似产品的环境会更容易一些。

stripe-payments

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

Laravel 和干预/图像:将照片上传到 AWS S3 存储桶会生成 0 字节文件

我在Laravel 中使用http://image.intervention.io/来调整图像大小,然后再将它们存储在 AWS S3 存储桶中。这是适用的代码:

$extension = $image->extension();
$realPath = $image->getRealPath();
$resizedImage = Image::make($realPath) // ->resize(255, 255); // resize or not, make() seems to always return an empty Image
$file_path = "posts/$post->id/images/image-$post->id-num-$pictureCount.$extension/"; 
$path = Storage::disk('s3')->put($file_path, $resizedImage->__toString(), ['visibility' => 'public']);
Run Code Online (Sandbox Code Playgroud)

调试时($path设置了线路上的断点),我可以看到它$realPath包含一个类似的值/private/var/folders/23/jl2dytp168g9g9s5j51w2m780000gn/T/php9047Fh- 去那里我可以看到我正在尝试的图像make()/ resize()

$resizedImage对象具有以下字段:

[encoded] => 
[mime] => image/jpeg
[dirname] => /private/var/folders/23/jl2dytp168g9g9s5j51w2m780000gn/T
[basename] => phpTNRdXe
[extension] => 
[filename] => phpTNRdXe
Run Code Online (Sandbox Code Playgroud)

我猜编码的属性应该包含类似 base 64 图像数据的内容?

检查 AWS S3 存储桶中的图像时,它总是作为 …

php image laravel-5 intervention php-7

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