小编ses*_*360的帖子

VueJS组件

我想利用VueJS组件来清理我的脚本.因此,我为Laravel加载的每个页面都有一个组件.到目前为止一切正常.但我有问题将我当前的脚本逻辑转移到组件.

这是导入要使用的组件的当前脚本设置:

main.js

import HomeView from './components/HomeView.vue';
import IncidentView from './components/IncidentView.vue';

window.app = new Vue({
   el: '.content',

   components: {
       HomeView, IncidentView
   },

   methods: {

       // Init GIS
      init: function() {

          // Initialize GIS Map
         initGISMap(this.$els.map);
      },
    }
(...)
}
Run Code Online (Sandbox Code Playgroud)

关键是我的window.app = new Vue...部分.我使用谷歌地图,因此当页面加载时,它搜索app.init方法.这是我在刀片模板中加载的脚本的一部分:

<!DOCTYPE html>
<html>
<body class="hold-transition skin-blue sidebar-mini">
        <section class="content-header">
            <h1>
                @yield('page_title')
                <small>@yield('page_description')</small>
            </h1>
        </section>

        <!-- Main content -->
        <section class="content">

            @if (isset($vueView))
                <component is="{{ $vueView }}">
            @endif
                @yield('content')
            </component>

        </section>
        <!-- /.content -->
<script src="https://maps.googleapis.com/maps/api/js?key=KEY&libraries=places&callback=app.init" …
Run Code Online (Sandbox Code Playgroud)

javascript laravel vue.js vuejs2

14
推荐指数
2
解决办法
3233
查看次数

Laravel X-CSRF-Token与POSTMAN不匹配

我尝试与使用Laravel构建的REST API交谈.但由于令牌不匹配,POSTMAN的调用被拒绝.我想我需要在标题中包含CSRF令牌.但我需要加密吗?当我插入此令牌时,我仍然会收到令牌不匹配的错误.

我使用以下方法检索我的令牌:

$encrypter = app('Illuminate\Encryption\Encrypter');
$encrypted_token = $encrypter->encrypt(csrf_token());
return $encrypted_token;
Run Code Online (Sandbox Code Playgroud)

但这应该在每次刷新时改变吗?

api csrf laravel postman

13
推荐指数
5
解决办法
2万
查看次数

推送通知加密错误

我在PHP Laravel应用程序中使用Push Notifs.我创建了一个pem文件并对其进行了测试.在我的开发机器上使用它时,它正确地推送到移动设备.当我现在将整个项目推送到我的生产服务器,并启动pushnotif调用时,我收到错误:Failed to enable crypto

在生产服务器上是否需要创建特殊的pem文件?我不是在谈论"生产证书"我仍然想使用沙箱进行测试

<?php

namespace App\Helpers;
use Carbon\Carbon;
use Illuminate\Support\Facades\Config;

class PushNotificationHelper {
    public function pushToResponder($deviceToken) {
        // Set device token of mobile device and the passphrase for certification
        $pushToken = $deviceToken;
        $passphrase = Config::get('MFConfig.PushNotificationTest.passPhrase');
        $APNS = Config::get('MFConfig.PushNotificationTest.APNS');

        // Open new context for streaming and set certificate as well as passphrase
        $ctx = stream_context_create();
        stream_context_set_option($ctx, 'ssl', 'local_cert', '../App/Certificates/ck.pem');
        stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
        stream_context_set_option($ctx, 'ssl', 'cafile', '../App/Certificates/entrust_2048_ca.cer');

        // Open connection to APNS
        $fp = stream_socket_client($APNS, $err, …
Run Code Online (Sandbox Code Playgroud)

php push-notification laravel

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

GoogleMaps不会在页面加载时加载

我无法使用GoogleMaps API V3运行我的地图.地图无法加载.我希望地图显示在带有ID的div中,gisMap但在Chrome调试器中,我收到消息:

Uncaught InvalidValueError: initMap is not a function
Run Code Online (Sandbox Code Playgroud)

使用Javascript

var map;

function initMap() {
    // Enabling new cartography and themes
    google.maps.visualRefresh = true;

    // Setting starting options
    var mapOptions = {
        center: new google.maps.LatLng(39.9078, 32.8252),
        zoom: 10,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    // Getting Map DOM Element
    var mapElement = document.getElementById('gisMap');

    // Creating a map with DOM element
    map = new google.maps.Map(mapElement, mapOptions);
}
Run Code Online (Sandbox Code Playgroud)

Bundle.js(摘录)

(...)
module.exports = Vue;
}).call(this,require('_process'))
},{"_process":1}],3:[function(require,module,exports){
'use strict';

var map;

function initMap() { …
Run Code Online (Sandbox Code Playgroud)

html javascript google-maps

12
推荐指数
2
解决办法
5万
查看次数

didRegisterForRemoteNotificationsWithDeviceToken停止被调用

我正在测试我的应用程序使用Push Notifs.它整天运作良好,突然停了下来.设置完全没有变化.经过多次调试后,我发现该函数didRegisterForRemoteNotificationsWithDeviceToken不再被调用.我在这个函数上设置了一个断点,当应用程序启动时,它根本没有被调用,或者我重新安装了应用程序.如果我想允许push notifs,我会得到动作表,但之后从未调用过委托.

    settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(settings!)
    UIApplication.sharedApplication().registerForRemoteNotifications()
Run Code Online (Sandbox Code Playgroud)

push-notification swift

12
推荐指数
0
解决办法
506
查看次数

带邮递员的PUT/PATCH请求在Laravel中返回状态码0

我编写了一些REST API方法,包括一个用于更新数据库条目的方法:

// Update
public function update(CreateAEDRequest $request, $id) {
    $aed = AED::find($id);

    if(!$aed) {
        return response()->json(['message' => "Dieser AED exisitiert nicht", 'code' => 404], 404);
    }

    $owner = $request->get('owner');
    $street = $request->get('street');

    $aed->owner = $owner;
    $street->street = $street;

    $aed->save();

    return response()->json(['message' => 'Der AED wurde aktualisiert'], 200);
}
Run Code Online (Sandbox Code Playgroud)

路线定义为:

    Route::put('/aeds/{aeds}', 'APIAEDController@update');
    Route::patch('/aeds/{aeds}', 'APIAEDController@update');
Run Code Online (Sandbox Code Playgroud)

正在处理请求:

<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;
use Illuminate\Http\JsonResponse;

class CreateAEDRequest extends Request
{
    public function authorize()
    {
        // turn back to false when doing auth
        return …
Run Code Online (Sandbox Code Playgroud)

php laravel postman

10
推荐指数
2
解决办法
7859
查看次数

避免在运行时向 Vue 实例或其根 $data 添加反应性属性 - 在 data 选项中预先声明。

我对使用 VueJS2 有点困惑。我向数据容器添加了一些变量,以便将其发送到我的 API。这工作正常,但 Vue 向我抛出了一条警告/错误消息,我不知道如何解决:

避免在运行时向 Vue 实例或其根 $data 添加反应性属性 - 在 data 选项中预先声明。

var app = new Vue({
    el: '#app',
    data: {
        incidentReference: '',
        streetName: '',
        latitude: '',
        longitude: '',
        featureTypeId: 1,
        archived: 0
    },

    computed: {
        href() {
            return '#' + this.name.toLowerCase().replace(/ /g, '-');
        }
    },

    mounted: function () {
        this.getIncidents();
    },

    methods: {
        onSubmit() {
            axios.post('/api/v1/incidents', this.$data)
                .then(response => alert('Success'))
                .catch(error => {
                    console.log(error.response);
                })
        },

        getIncidents: function() {
            console.log('getIncidents');
            var self = this;
            axios.get('/api/v1/incidents').then(function(response) { …
Run Code Online (Sandbox Code Playgroud)

laravel vue.js

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

Laravel 5.1本地化工厂播种机

我实施了一个新工厂来生成随机数据.但是我希望以de_DE的格式提供这个随机数据.所以通常我首先创建一个faker对象,但是在Laravel 5.1中使用新的ModelFactory类并不是这样.我如何本地化呢?

$factory->define(App\Models\AED::class, function($faker) {
    return [
        'owner' => $faker->company,
        'street' => $faker->streetAddress,
        'latitude' => $faker->latitude,
        'longitude' => $faker->longitude
    ];
});
Run Code Online (Sandbox Code Playgroud)

php database laravel

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

Laravel中的VueJS设置

我安装了VueJS2用于laravel.从简单的测试设置开始,这是app.blade.php

<!DOCTYPE html>
<html>
<head>
    <script scr="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.6/vue.min.js"></script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MEDIFAKTOR - @yield('title') </title>
    <link rel="stylesheet" href="css/vendor.css" />
    <link rel="stylesheet" href="css/app.css" />
</head>
<body>

  <!-- Wrapper-->
    <div id="wrapper">
        <!-- Navigation -->
        @include('layouts.navigation')
        <!-- Page wraper -->
        <div id="page-wrapper" class="gray-bg">
            <!-- Page wrapper -->
            @include('layouts.topnavbar')
            <!-- Main view  -->
            @yield('content')
            <!-- Footer -->
            @include('layouts.footer')
        </div>
        <!-- End page wrapper-->
    </div>
    <!-- End wrapper-->
<script src="js/app.js" type="text/javascript"></script>
  <script>
      var data = {
          message: 'Greetings your majesty'
      };
      new …
Run Code Online (Sandbox Code Playgroud)

laravel gulp vue.js

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

laravel 的 nginx 配置

我为 nginx 创建了这个配置文件来访问我的 Laravel 页面:

server {
    listen 80;
    listen [::]:80;

    root /var/www/mfserver/public;
    index index.php index.html index.htm;

    server_name dispo.medifaktor.de;

    location / {
        try_files $uri $uri/ /index.php?is_args$args;
    }

    error_page 404 /index.php;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/mfserver/public;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我调用页面 dispo.medifaktor.de 时,我看到了主页。但是当我调用http://dispo.medifaktor.de/v1/incidents 时,我收到了一个服务器错误 500。为什么我不能访问这些页面?

路由文件正在工作:

Route::group(['domain' …
Run Code Online (Sandbox Code Playgroud)

php nginx laravel

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