Javascript 使用Vuejs在JS文件中使用库
我想在其他外部JS文件中使用库,以便在调用原型时 大概是这样的:Javascript 使用Vuejs在JS文件中使用库,javascript,vue.js,dependencies,vuetify.js,prototype,Javascript,Vue.js,Dependencies,Vuetify.js,Prototype,我想在其他外部JS文件中使用库,以便在调用原型时 大概是这样的: this.$callback.handler() 我的原型: export default function(Vue, options = {}) { Vue.callback = { handler: () => { // this.$dialog.notify.success( // "Text here",
this.$callback.handler()代码>
我的原型:
export default function(Vue, options = {}) {
Vue.callback = {
handler: () => {
// this.$dialog.notify.success(
// "Text here",
// {
// position: "top-right",
// timeout: 5000
// }
// );
}
};
Object.defineProperties(Vue.prototype, {
$callback: {
get: () => {
return Vue.callback;
}
}
});
}
因此,在这种情况下,this.$dialog
无法识别(请注意:'dialog'是基于Vuetifyjs的vuetify对话框库)
此外,我还尝试在app.js中使用以下工具实现VueityDialog:
import Callback from "./apis/Callback";
Vue.use(Callback, { context: { VuetifyDialog } });
有什么解决方案吗?对处理程序
和$callback.get
使用常规函数。能给我看一下代码片段吗?我会感谢你的