道歉,如果这似乎我错过了一些非常明显的东西。 (我使用的是用npm和骨干构建的应用程序) 我正在尝试使用common.js
加载我的datetimepicker模块Route::post('apply/upload/image/{type}', 'DLMM\News\Http\Controllers\ApplyController@upload');
当我在我的应用中添加datetimepicker时,我得到:
public function upload($type, Request $request)
{
switch ($type) {
case 'title_news': {
upload_main_pic_news($request);
break;
}
}
}
public function upload_main_pic_news(Request $request)
{
$validation = \Illuminate\Support\Facades\Validator::make($request->all(),
['mainImage' => 'required|image|max:1000',],
['required' => 'عکسی انتخاب نشده است.', 'image' => 'فایل انتخاب شده عکس نمی باشد.', 'max' => 'حداکثر اندازه عکس می تواند 1000 کیلوبایت باشد.',]);
if ($validation->passes()) {
$destinationPath = 'uploads'; // upload path
$fileName = $request->file('mainImage')->getClientOriginalName(); // renameing image
$request->file('mainImage')->move($destinationPath, $fileName); // uploading file to given path
return response()->json([
'success' => true,
'message' => 'image uploaded'
], 200);
}
$errors = $validation->errors();
//$errors = json_encode($errors);
return response()->json([
'success' => false,
'message' => $errors
], 422);
}
当我查看调试器时,我可以看到模块没有加载。 它已安装在我的节点模块文件夹中。我只是想知道任何人都可以看到任何明显的我可能会失踪的东西。 我已经导入了moment和jquery,因为它们是列出的依赖项。 它们在datetimepicker之前导入/加载。 非常感谢任何帮助。
答案 0 :(得分:0)
尝试
window.datetimepicker = require('eonasdan-bootstrap-datetimepicker');
还要确保加载此库所需的moment.js