Bootstrap 4下拉菜单在Laravel-Vue spa中不起作用
Spa.blade.php文件Bootstrap 4下拉菜单在Laravel-Vue spa中不起作用,laravel,vue.js,bootstrap-4,popper.js,Laravel,Vue.js,Bootstrap 4,Popper.js,Spa.blade.php文件 <!doctype html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <title>SPA</title> <link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i%7
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<title>SPA</title>
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i%7COpen+Sans:300,300i,400,400i,600,600i,700,700i" rel="stylesheet">
<!-- Bootstrap 4.4 -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Custom stylesheet -->
<link rel="stylesheet" href="{{ asset('frontend/style.css') }}">
<!-- include the site responsive stylesheet -->
<link rel="stylesheet" href="{{ asset('frontend/css/responsive.css') }}">
</head>
<body>
<div id="app">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
有人能建议如何解决这个问题吗?请仔细研究一下。它正在工作。请检查您正在使用的所有CDN或缺少某些内容。
温泉
下拉按钮
我没有注意到bootstrap.js默认情况下会加载popper和jquery,因此无需再次导入这些CDN链接
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
app.js就足够了,它可以加载所有必要的依赖项
<script src="{{ asset('js/app.js') }}"></script>
您是否缺少css表?如果我们删除app.js(Vue实例),它可以工作,但问题是,导入Vue实例时它不工作。
<script src="{{ asset('js/app.js') }}"></script>