首页 > 解决方案 > 如何解决 ReferenceError: $ is not defined, on Remote server?

问题描述

在我正在运行的 Laravel 应用程序中,我突然收到一个远程错误:

ReferenceError: $ is not defined @ https/ ... edit_profile.php:2:1

该应用程序曾经顺利运行。在本地,该应用程序仍然可以正常工作,但是当我将其推送到生产环境时,我得到了错误。

有人可以帮我找出问题所在吗?我害怕在远程服务器端破坏某些东西

<script>
$( 'button' ).click(function(){
   $( '#file_picture_input' ).click(); 
});

$( '#file_picture_input').change(function(){
   $( 'span' ).text($( this ).val() ); 
});
</script> 

它引用的视图是edit_profile:

@extends('layout')

@section('header')
    @include('includes.basic_header')
@stop

@section('content')
    <div class="container minigame-container">
        <div class="row minigame-text-row">
            <div class="col text-center">
                @if (!$valid)
                    <p><b>{{ __('Welcome at Detective Collective!') }}</b><p>
                    
                    <p>{{ __('Before you begin with solving crimes, you first need to finish your profile.') }}</p>
                @endif
            </div>
        <div class="row">
        <div class="row minigame-text-row">
            <div class="col text-center">
                <h5 class="header_dark">{{ __('My Profile') }}</h5>
                <form method='POST' id="account_form" runat="server" action="profile/submit" enctype="multipart/form-data">
                    {{ csrf_field() }}
                    @foreach ($errors->all() as $error)
                        <h6 class="red">{{ $error }}</h6>
                    @endforeach
                    <b>{{ __('Profile photo') }}</b>

                </form>
                </div>
            </div>
        </div>
    </div>
 <script src="{{ url('js/cropimage.js') }}" ></script>

@stop


@section('footer')
    @include('includes.basic_footer')
@stop

<script>
$( 'button' ).click(function(){
   $( '#file_picture_input' ).click(); 
});

$( '#file_picture_input').change(function(){
   $( 'span' ).text($( this ).val() ); 
});
</script>

jquery 由 bootstrap.js 引入

window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');

标签: jquerylaravel

解决方案


推荐阅读