Vue特殊使用方法
3106 ワード
1. vue
Vue.nextTick(function () {
alert(123);
});
2 vueメソッドの呼び出し
--------------Vue
/**
*
* fmt : 'yyyy-MM-dd hh:mm:ss';
*/
Vue.filter('dataFormat', function (value,fmt) {
var getDate = new Date(value);
var o = {
'M+': getDate.getMonth() + 1,
'd+': getDate.getDate(),
'h+': getDate.getHours(),
'm+': getDate.getMinutes(),
's+': getDate.getSeconds(),
'q+': Math.floor((getDate.getMonth() + 3) / 3),
'S': getDate.getMilliseconds()
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt;
});
var vm = new Vue({
el:'#app',
data:{
date:new Date();
},
methods:{
aaa:function(){
//
vm.$options.filters['dataFormat'](vm.date,'yyyyMM');
}
}
})
Vue
{{date | dataFormat('yyyyMM')}}