如何将'bootstrap-datetimepicker'导入Aurelia项目 [英] How to import 'bootstrap-datetimepicker' into Aurelia project
问题描述
我正在尝试将'Eonasdan/bootstrap-datetimepicker'添加到带有打字稿项目的Aurelia中,并在Aurelia生活中附加"方法中调用 this.birthDateDatePicker.datetimepicker();
循环.
I'm trying to add 'Eonasdan/bootstrap-datetimepicker' into an Aurelia with typescript project and call this.birthDateDatePicker.datetimepicker();
in the "attached" method from the Aurelia life-cycle.
我添加了:
import $ from 'jquery';
import {datepicker} from 'Eonasdan/bootstrap-datetimepicker';
没有错误,但是当我尝试像这样 @inject(HttpClient,json,datepicker)
注入时,出现以下错误:
and there was no error,
but when I try to inject like this @inject(HttpClient, json, datepicker)
I get the following error:
GET http://127.0.0.1:8080/jquery.js 404(未找到)
我不确定这两个库是否已加载,因为我无法在浏览器调试器的源代码中找到它们.
I'm not sure the two libraries are loaded because I cannot find them in the sources on the browser debugger.
我在做什么错了?
该行的错误是
未处理的承诺拒绝TypeError:this.birthDateDatePicker.datetimepicker不是函数"
"Unhandled promise rejection TypeError: this.birthDateDatePicker.datetimepicker is not a function"
解决方案:
我添加了以下导入:
import $ from 'jquery';
import 'Eonasdan/bootstrap-datetimepicker';
并在config.js中手动添加休憩图:
and manually added in the config.js the fallowing map:
"jquery":"github:components/jquery@2.2.0",
评论/问题:我不确定在此处手动添加它是否是个好主意,但是我无法像骨架应用程序那样从引导程序中使用它,我看到它存在于package.json的全局依赖项中文件,并在"jspm_packages/github/components"下找到它.
Comment/Question: I'm not sure if it's a good idea to manually add it there but I could not use it from bootstrap like in the skeleton application and I saw it was present in the global dependencies of the package.json file and found it under "jspm_packages/github/components".
这是正确的方法吗?
谢谢
推荐答案
如果您使用aurelia-skeleton作为样板
if you use aurelia-skeleton as boilerplate
import $ from 'bootstrap';
还可以使用 import'Eonasdan/bootstrap-datetimepicker';
将datetimepicker作为jquery模块添加到全局变量中
EDITED:
Also use import 'Eonasdan/bootstrap-datetimepicker';
to add datetimepicker as jquery module to globals
这篇关于如何将'bootstrap-datetimepicker'导入Aurelia项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!