nara 패키지를 Laravel에 설치 한 후 npm 패키지를 설치하는 방법은 무엇입니까?Laravel에 npm 패키지를 설치 한 후 npm 패키지를 설치하는 방법은 무엇입니까?
예를 들어, 나는 sweetalert2
패키지가 필요 먼저 설치 :
npm install --save sweetalert2
지금, laravel에서 \resources\assets\js\bootstrap.js
파일을 요구해야합니까?
window._ = require('lodash');
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
window.axios = require('axios');
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
그것은 lodash
, jquery
, bootstrap
이 axios
이 laravel에 필요하지만 4 개 문장이 다른 한 것처럼, 그들은이처럼 보이는 :
window._ = require('lodash');
window.$ = window.jQuery = require('jquery');
require('bootstrap');
window.axios = require('axios');
그것의 기본 내용은 다음과 같이이다
질문 :
1, 왜 4 문장의 차이점이 있습니까?
2, 패키지 sweetalert2
을 쓰고 싶습니다. 어떻게 작성합니까? 귀하의 항목 .scss 파일 (당신이 scss
를 사용하는 가정) 다음
require('sweetalert2');
:
@ zwl1619이 대답에 대한 답변을 얻었습니까? –