简体   繁体   中英

PHP Laravel - link external Javascript and CSS file

I am encountering problems when trying to include the jQuery date/time picker in my appointment booking system. I have followed the Laravel convention as best I could and seem to still have no luck.

File path for css file: public/css/file_is_here

File path for js: public/js/files_are_here

A snippet of the code I tried to reference the files is below:

<link rel="stylesheet" type="text/css" href="{{ URL::asset('/css/jquery.datetimepicker.min.css') }}"/>
<script type="text/javascript" src="{{ URL::asset('/js/jquery.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('/js/jquery.datetimepicker.full.min.js') }}"></script>
<script>jQuery('#datetimepicker').datetimepicker({
    step: 30
});</script>

The input field is also shown:

<div class="col-md-6">
    <input id="datetimepicker" type="text" class="form-control">
</div>

Any help appreciated.

在此处输入图像描述

**Discovered weird bug whenever the page loads in the calendar will display for a second before disappearing. Could this be due to some other js, jquery or css loading in? **

Assets are typically kept in packages. If you are in public/css and public/js then you can treat "public" like a webroot.

src="/js/jquery.js"

 <script src="{{ asset('public/plugins/datetime/jquery.datetimepicker.full.js') }}"></script> <link rel="stylesheet" type="text/css" href="{{ asset('public/plugins/datetime/jquery.datetimepicker.css') }}" />

it's work with me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM