PHP Laravel Instascan“无法加载脚本......”

时间:2017-09-14 23:20:55

标签: laravel-5

此刻我与laravel取得了联系。我试图创建一个扫描qr代码的页面。

我用laravel(composer create-project laravel / laravel testqrinstascan)创建了一个普通的项目,并尝试逐步实施instascan。

我想使用这个库instascan - > https://github.com/schmich/instascan

但我每次都会收到错误“Ladenfehlgeschlagenfürdasmit der Quelle”http://localhost:8000/instascan.min.js“。”

但该文件位于同一目录

这意味着用源代码加载脚本....不可能 - > https://imgur.com/a/SKang

这是我的welcome.blade.php --------------------------------------- ---------------------------------

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Laravel</title>

    <script type="text/javascript" src="instascan.min.js"></script>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <style>
        html, body {
            background-color: #fff;
            color: #636b6f;
            font-family: 'Raleway', sans-serif;
            font-weight: 100;
            height: 100vh;
            margin: 0;
        }

        .full-height {
            height: 100vh;
        }

        .flex-center {
            align-items: center;
            display: flex;
            justify-content: center;
        }

        .position-ref {
            position: relative;
        }

        .top-right {
            position: absolute;
            right: 10px;
            top: 18px;
        }

        .content {
            text-align: center;
        }

        .title {
            font-size: 84px;
        }

        .links > a {
            color: #636b6f;
            padding: 0 25px;
            font-size: 12px;
            font-weight: 600;
            letter-spacing: .1rem;
            text-decoration: none;
            text-transform: uppercase;
        }

        .m-b-md {
            margin-bottom: 30px;
        }
    </style>

</head>
<body>
    <div class="flex-center position-ref full-height">

        <div class="content">
            <div class="links">
                <video id="preview"></video>
                Hello World

                <script type="text/javascript">
                    let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
                    scanner.addListener('scan', function (content) {
                        console.log(content);
                    });
                    Instascan.Camera.getCameras().then(function (cameras) {
                        if (cameras.length > 0) {
                            scanner.start(cameras[0]);
                        } else {
                            console.error('No cameras found.');
                        }
                    }).catch(function (e) {
                        console.error(e);
                    });
                </script>

            </div>
        </div>
    </div>
</body>

0 个答案:

没有答案