dataSource.js 550 Bytes
import { ref } from "vue";
import http from "@/api/http";
let api = ref("");
let source = ref([]);
let total = ref(0);
const getData = (params = {}) => {
  http.get(api.value, params).then((res) => {
    source.value = res.data;
    console.log(source.value);
  });
};
export default {
  install(app) {
    app.directive("dataSource", {
      mounted(el, binding) {
        api.value = binding.value;
        getData();
      },
      updated(el, binding) {
        console.log("updated");
      },
    });
  },
};
export { source, total, getData };