我使用最新的 Vue cli 创建了该应用程序,并且我试图注册一个全局自定义指令但没有成功。有人可以告诉我我在这里做错了什么吗?
import { createApp } from "vue";
import App from "./App.vue";
import "./registerServiceWorker";
import router from "./router";
import store from "./store";
const app = createApp(App);
app.directive("highlight", {
beforeMount(el, binding, vnode) {
el.style.background = binding.value;
},
});
app
.use(store)
.use(router)
.mount("#app");