今天做了一个dome,是关于vue-full-calendar的,在公司用的是angluar,自己在家自学vue,遇到了个问题,上网查了好久,都没有遇到的问题,后来找了一个大神的demo,对比了一下,发现了个特别低级的错误,记录一下
首先,导入依赖,
npm install --save vue-full-calendar
然后在需要引入calendar的模板中引包
import { FullCalendar } from 'vue-full-calendar'
import "fullcalendar/dist/fullcalendar.css";
在components中添加模板
components: { FullCalendar },
HTML中加入full-calendar
<full-calendar ref="calendar" style="height: 100%" :options="calendarOptions"></full-calendar>
在data中添加要显式的data内容等
data() {
return {
date_pick_text: '',
pickerOptions: {
disabledData(time) {
return time.getTime() > Date.now();
},
shotcuts: [
{ text: "今天",
onClick(picker) {
picker.$emit('pick', new Date());
}
},
{ text: "昨天",
onClick(picker) {
var date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date.getTime());
}
}
]
},
calendarOptions: {
headerToolbar: false,
height: 650,
handleWindowResize: true, //是否随着窗口大小变化
initialView: 'dayGridMonth'
}
}
},
然后我启动就报错,
This dependency was not found:
* jquery in ./node_modules/fullcalendar/dist/fullcalendar.js, ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/vue-full-calendar/components/FullCalendar.vue?vue&type=script&lang=js&
查了好久,怎么都报错,后来对比了大神的demo后发现,我没有依赖jQuery,
npm install jquery
好用了!
在自学vue.js时,尝试实现vue-full-calendar组件。通过安装依赖、引入样式和模板,设置组件数据和选项,但在启动时遇到错误,提示缺少jquery。经过查找和对比他人示例,发现需额外安装jquery才能解决问题。
2510





