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'))
        });
      },
Logo

前往低代码交流专区

更多推荐