互联网企业网站模板,wordpress 安装语言,专题页网站,哪个网站做h5最好为什么要做
quasar是个基于vue的强大的UI开发库#xff0c;它提供了非常多的组件#xff0c;比如日期选择。但是有些时候只需要选择到月份就可以了#xff0c;quasar中没有#xff0c;所以自己动手写了一个。因为对界面编程我不熟悉#xff0c;所以#xff0c;如果你有更…为什么要做
quasar是个基于vue的强大的UI开发库它提供了非常多的组件比如日期选择。但是有些时候只需要选择到月份就可以了quasar中没有所以自己动手写了一个。因为对界面编程我不熟悉所以如果你有更好的想法请不吝赐教。源码在gitcode、gitee、github的至简网格/企业服务上都有以Apache License协议开源gitcode连接如下
assets/file/v3/components/month_input.js · master · 至简网格 / 企业服务 · GitCode
用法
1先引入
import MonthInput from path_to_components/month_input.js
2再注册
组件中注册components:{month-input:MonthInput}
或全局注册app.component(month-input, MonthInput); app是使用Vue.createApp创建的。
3最后使用
month-input classjustify-center text-primary min-5 maxcur update:modelValuef/month-input
属性
min、max、monthName(默认为“月”)
min、max接受以下几种格式cur当前月份、-x当前年度减x年x当前年度加x年yyyy/MM、yyyy-MM或yyyy.MM具体的月份不设置则不限制。
update:modelValue触发回调时传递一个对象其中包括{year:年份,month:月份(从1开始),num:年份*12月份-1}
操作
没有点击时显示如下 点击左右箭头前移一个月或后移一个月点击中间的年/月显示一个弹窗在min、max指定范围之外的年月显示为灰色如果选中的年份不在当前年份列表页中月份全部显示灰色。点击左右箭头前移或后移12年。先选择年份然后选择月份就可以了触发update:modelValue同时隐藏弹窗。 源码 //月份选择组件month-input
export default{
data(){return {maxMonth:0,minMonth:0,year:,month:,num:0,//year*12month-1startYear:0,years:[],months:[],old:{y:0,m:0}
}},
props: {modelValue:{type:String},min:{type:String,default:}, //年份max:{type:String,default:},monthName:{type:String, default:月}
},
emits: [update:modelValue],
created(){var mthis.parse(this.max,{y:9999,m:1});this.maxMonthm.y*12m.m-1;mthis.parse(this.min,{y:0,m:1});this.minMonthm.y*12m.m-1;var dtnew Date();mthis.parse(this.modelValue,{y:dt.getFullYear(),m:dt.getMonth()1})this.old{year:m.y, month:m.m};this.yearm.y;this.monthm.m;this.numthis.year*12this.month-1;this.startYearthis.year-4;this.set_array();
},
methods:{
set_array() {var month;var list[];var chkedfalse;var vthis.startYear;var yMaxMath.floor(this.maxMonth/12);var yMinMath.floor(this.minMonth/12);for(var i0;i4;i) {var yy[];for(var j0;j3;j) {var y{v:v,cls:col text-center};if(vyMax||vyMin) {y.cls text-grey;} else if(vthis.year) {y.cls bg-primary text-white;chkedtrue;}yy.push(y);v;}list.push(yy);}this.yearslist;v1;list[];for(var i0;i4;i) {var mm[];for(var j0;j3;j) {var m{v:v,cls:col text-center};if(chked) {//所选年份可见monththis.year*12v-1;if(monththis.maxMonth||monththis.minMonth) {m.cls text-grey;} else if(vthis.month) {m.cls bg-primary text-white;}} else {m.cls text-grey;}mm.push(m);v;}list.push(mm);} this.monthslist;
},
parse(s,def) {if(!s) {return def;}var cfgs.trim().toLowerCase();var dtnew Date();if(cfgcur) {return {y:dt.getFullYear(),m:dt.getMonth()1};}if(cfg.startsWith(-)) {var v parseInt(cfg.substring(1));return {y:dt.getFullYear()-v, m:1};}if(cfg.startsWith()) {var v parseInt(cfg.substring(1));return {y:dt.getFullYear()v, m:1};}var y,m;var pcfg.indexOf(/);if(p0)pcfg.indexOf(-);if(p0)pcfg.indexOf(.);if(p0) {yparseInt(cfg.substring(0,p));mparseInt(cfg.substring(p1));} else {yparseInt(cfg);m1;}return {y:y,m:m};
},
pageUp() {this.startYear-12;this.set_array();
},
pageDn() {this.startYear12;this.set_array();
},
fore(){if(this.numthis.minMonth)return;this.month--;if(this.month0) {this.year--;this.month12;}this.numthis.year*12this.month-1;this.old{year:this.year, month:this.month,num:this.num};this.$emit(update:modelValue, this.old);
},
next(){if(this.numthis.maxMonth)return;this.month;if(this.month12) {this.year;this.month1;}this.numthis.year*12this.month-1;this.old{year:this.year, month:this.month,num:this.num};this.$emit(update:modelValue, this.old);
},
set_year(v) {var yMaxMath.ceil(this.maxMonth/12);var yMinMath.floor(this.minMonth/12);if(vyMax||vyMin) {return;}this.month-1;this.yearv;this.set_array();
},
set_month(v) {if(this.yearthis.startYear||this.yearthis.startYear12) {return;//未选择年份}var mv-1this.year*12;if(mthis.maxMonth||mthis.minMonth) {return; //不在有效范围内}this.monthv;if(v!this.old.month||this.year!this.old.year) {this.numthis.year*12this.month-1;this.old{year:this.year, month:this.month,num:this.num};this.$emit(update:modelValue,this.old);}this.$refs._my_dlg.hide();
}
},
computed: {value: {get() {return this.year/(this.month9?this.month:(0this.month))},set(v) {var ymthis.parse(v);this.yearym.y;this.monthym.m;this.numthis.year*12this.month-1;}}
},
template:
div classrowdiv classrol q-pr-lgq-icon namenavigate_before clickfore:classnumminMonth?text-grey:/q-icon/divdiv classrol stylecursor:pointer{{year}} / {{month10?(0month):month}}q-popup-proxy cover before-showset_array ref_my_dlgdiv classrow q-pa-sm stylemin-width:20em;div classcol self-centerq-icon namenavigate_before clickpageUp size2em classq-px-sm/q-icon/divdiv classcol-8div classrow v-foryy in yearsdiv v-fory in yy :classy.cls clickset_year(y.v)stylecursor:pointer{{y.v}}/div/divq-separator spacedmd/q-separatordiv classrow v-formm in monthsdiv v-form in mm :classm.cls clickset_month(m.v)stylecursor:pointer{{m.v}}{{monthName}}/div/div/divdiv classcol self-centerq-icon namenavigate_next clickpageDn size2em classq-px-sm/q-icon/div/div/q-popup-proxy/divdiv classrol q-pl-lgq-icon namenavigate_next clicknext:classnummaxMonth?text-grey:/q-icon/div
/div}
文章转载自: http://www.morning.lwqst.cn.gov.cn.lwqst.cn http://www.morning.jwdys.cn.gov.cn.jwdys.cn http://www.morning.gmyhq.cn.gov.cn.gmyhq.cn http://www.morning.wtwhj.cn.gov.cn.wtwhj.cn http://www.morning.qbccg.cn.gov.cn.qbccg.cn http://www.morning.lmrjn.cn.gov.cn.lmrjn.cn http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn http://www.morning.fgsqz.cn.gov.cn.fgsqz.cn http://www.morning.pmrlt.cn.gov.cn.pmrlt.cn http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn http://www.morning.yjprj.cn.gov.cn.yjprj.cn http://www.morning.mysmz.cn.gov.cn.mysmz.cn http://www.morning.rmdwp.cn.gov.cn.rmdwp.cn http://www.morning.kqxng.cn.gov.cn.kqxng.cn http://www.morning.rpjr.cn.gov.cn.rpjr.cn http://www.morning.hghhy.cn.gov.cn.hghhy.cn http://www.morning.khntd.cn.gov.cn.khntd.cn http://www.morning.cpktd.cn.gov.cn.cpktd.cn http://www.morning.cniedu.com.gov.cn.cniedu.com http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.yjmns.cn.gov.cn.yjmns.cn http://www.morning.qxmnf.cn.gov.cn.qxmnf.cn http://www.morning.lzqxb.cn.gov.cn.lzqxb.cn http://www.morning.rblqk.cn.gov.cn.rblqk.cn http://www.morning.dtnyl.cn.gov.cn.dtnyl.cn http://www.morning.jqhrk.cn.gov.cn.jqhrk.cn http://www.morning.zpfqh.cn.gov.cn.zpfqh.cn http://www.morning.ffhlh.cn.gov.cn.ffhlh.cn http://www.morning.jwfkk.cn.gov.cn.jwfkk.cn http://www.morning.xnqjs.cn.gov.cn.xnqjs.cn http://www.morning.lsmgl.cn.gov.cn.lsmgl.cn http://www.morning.lgwjh.cn.gov.cn.lgwjh.cn http://www.morning.ltpmy.cn.gov.cn.ltpmy.cn http://www.morning.nmtyx.cn.gov.cn.nmtyx.cn http://www.morning.tmsxn.cn.gov.cn.tmsxn.cn http://www.morning.hnpkr.cn.gov.cn.hnpkr.cn http://www.morning.cjqqj.cn.gov.cn.cjqqj.cn http://www.morning.ryjl.cn.gov.cn.ryjl.cn http://www.morning.gqfbl.cn.gov.cn.gqfbl.cn http://www.morning.jbxd.cn.gov.cn.jbxd.cn http://www.morning.kscwt.cn.gov.cn.kscwt.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.nzfyx.cn.gov.cn.nzfyx.cn http://www.morning.tfznk.cn.gov.cn.tfznk.cn http://www.morning.mtsgx.cn.gov.cn.mtsgx.cn http://www.morning.krjrb.cn.gov.cn.krjrb.cn http://www.morning.xpzrx.cn.gov.cn.xpzrx.cn http://www.morning.hmxrs.cn.gov.cn.hmxrs.cn http://www.morning.sgbk.cn.gov.cn.sgbk.cn http://www.morning.hbfqm.cn.gov.cn.hbfqm.cn http://www.morning.dzqr.cn.gov.cn.dzqr.cn http://www.morning.qsy39.cn.gov.cn.qsy39.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.xnqjs.cn.gov.cn.xnqjs.cn http://www.morning.qrwdg.cn.gov.cn.qrwdg.cn http://www.morning.nhlyl.cn.gov.cn.nhlyl.cn http://www.morning.jrpmf.cn.gov.cn.jrpmf.cn http://www.morning.pmmrb.cn.gov.cn.pmmrb.cn http://www.morning.swkzr.cn.gov.cn.swkzr.cn http://www.morning.nwjzc.cn.gov.cn.nwjzc.cn http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn http://www.morning.ljdhj.cn.gov.cn.ljdhj.cn http://www.morning.zdnrb.cn.gov.cn.zdnrb.cn http://www.morning.jlgjn.cn.gov.cn.jlgjn.cn http://www.morning.bloao.com.gov.cn.bloao.com http://www.morning.dmtld.cn.gov.cn.dmtld.cn http://www.morning.jjxxm.cn.gov.cn.jjxxm.cn http://www.morning.glwyn.cn.gov.cn.glwyn.cn http://www.morning.knjj.cn.gov.cn.knjj.cn http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn http://www.morning.rdpps.cn.gov.cn.rdpps.cn http://www.morning.rgpsq.cn.gov.cn.rgpsq.cn http://www.morning.nmfxs.cn.gov.cn.nmfxs.cn http://www.morning.synkr.cn.gov.cn.synkr.cn http://www.morning.ndpwg.cn.gov.cn.ndpwg.cn http://www.morning.rknsp.cn.gov.cn.rknsp.cn http://www.morning.drrt.cn.gov.cn.drrt.cn http://www.morning.wkws.cn.gov.cn.wkws.cn http://www.morning.tqjwx.cn.gov.cn.tqjwx.cn