vue 全局引用dayjs(笔记)
1、main.js引用import Vue from 'vue'import App from './App.vue'import word from '@/components/Word'import axios from "axios";import day from "dayjs";Vue.prototype.axios=axios;Vue.prototype.dayjs=day;Vue.c
·
1、main.js引用
import Vue from 'vue'
import App from './App.vue'
import word from '@/components/Word'
import axios from "axios";
import day from "dayjs";
Vue.prototype.axios=axios;
Vue.prototype.dayjs=day;
Vue.component('MyWord',word)
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')
2、组件调用
sub() {
let dayjs = this.dayjs;//不能在方法返回中直击使用this.dayjs
this.axios.get("http://localhost:8082/user/" + this.name).then(function (rst) {
console.log(dayjs(rst.data.times).format('YYYY.MM.DD'))
});
},
更多推荐
已为社区贡献3条内容
所有评论(0)