我是emebr-js
的初学者我为我的大学项目创建应用程序,我为我的应用程序添加一些第三方日历,我想在这个应用程序中添加一些java脚本,其中包括这个第三部分脚本,即时通讯尝试添加此route
> Profile.js
但不能正常工作,如何为profile.hbs
添加此脚本
hbs
页面名称Profile.hbs
这是我的剧本
<script type="text/javascript">
var calendarPicker2 = $("#dsel2").calendarPicker({
monthNames:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
useWheel:true,
//callbackDelay:500,
years:0,
months:0,
days:3,
showDayArrows:false,
callback:function(cal) {
}});
</script>
答案 0 :(得分:1)
我会鼓励你从https://emberobserver.com/
寻找余烬所以,如果只想使用w3widgets.com/responsive-calendar
对于此代码,
<script src="js/jquery.js"></script>
<script src="js/responsive-calendar.js"></script>
<link href="css/responsive-calendar.css" rel="stylesheet" media="screen">
如何设置ember使用插件
responsive-calendar.js
个文件放入app-name/vendor/responsive-calendar.js
和app-name/ember-cli-build.js
文件中{icer app.import('vendor/responsive-calendar.js')
responsive-calendar.css
个文件放入app-name/styles/responsive-calendar.css
并打开app.css
并添加以下行@import 'responsive-calendar.css';
现在它的插件已经可以使用了。
如何使用
通过运行命令ember g component my-calendar
创建名为my-calendar的组件,它将创建my-calendar.hbs和my-calendar.js文件。
在my-calendar.hbs中,放置所需的标记代码
<!-- Responsive calendar - START -->
<div class="responsive-calendar">
<div class="controls">
<a class="pull-left" data-go="prev"><div class="btn"><i class="icon-chevron-left"></i></div></a>
<h4><span data-head-year></span> <span data-head-month></span></h4>
<a class="pull-right" data-go="next"><div class="btn"><i class="icon-chevron-right"></i></div></a>
</div><hr/>
<div class="day-headers">
<div class="day header">Mon</div>
<div class="day header">Tue</div>
<div class="day header">Wed</div>
<div class="day header">Thu</div>
<div class="day header">Fri</div>
<div class="day header">Sat</div>
<div class="day header">Sun</div>
</div>
<div class="days" data-group="days">
<!-- the place where days will be generated -->
</div>
</div>
<!-- Responsive calendar - END -->
并在my-calendar.js文件中
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
this.$('.responsive-calendar').responsiveCalendar();
}
});
那就是它。您可以在任何模板中加入my-calendar组件,例如{{my-calendar }}