[英]How do I import Progressbar.js in Laravel?
我試圖在Laravel 5.6中使用此進度條 。 根據Progress.js文檔,您可以執行以下操作:
var ProgressBar = require('progressbar.js')
在默認的assets/js/bootstrap.js
文件中,我有:
window._ = require('lodash');
window.Popper = require('popper.js').default;
window.ProgressBar = require('progressbar.js');
但是當我嘗試在前端使用progressbar is undefined
時,仍然得到progressbar is undefined
。 您可以訪問Lodash和Popper。
當我將鼠標懸停在window.ProgressBar = require('progressbar.js');
在VCS中,它說:
找不到模塊“ progressbar.js”的聲明文件。
“ /Users/proevilz/sites/stream-raiders/node_modules/progressbar.js/src/main.js”隱式具有“ any”類型。
嘗試
npm install @types/progressbar.js
如果存在)或添加一個包含declare module 'progressbar.js';
的新聲明(.d.ts)文件declare module 'progressbar.js';
我做了它的建議,但是從NPM收到一個錯誤,指出沒有類型。
main.js
包含:
module.exports = {
// Higher level API, different shaped progress bars
Line: require('./line'),
Circle: require('./circle'),
SemiCircle: require('./semicircle'),
// Lower level API to use any SVG path
Path: require('./path'),
// Base-class for creating new custom shapes
// to be in line with the API of built-in shapes
// Undocumented.
Shape: require('./shape'),
// Internal utils, undocumented.
utils: require('./utils')
};
我到底在做什么錯? 是否可以在不顯式引用HTML文件中的progressbar.js
文件的情況下加載此程序包?
在對流進行更多幫助之后,問題似乎在於它沒有保存為開發依賴項,而是保存為常規依賴項。 解決方法是將其移至package.json
文件中並運行npm install
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.