【发布时间】:2023-03-21 22:40:01
【问题描述】:
我正在学习制作Vue插件,基于https://vuejs.org/v2/guide/plugins.html, 这是我的简单代码:
plugin1.js:
AlertPlugin.install = function (Vue, options) {
Vue.prototype.$classicalert = function (message) {
alert(message)
};
};
app.js:
window.Vue = require('vue');
import AlertPlugin from './plugin1.js'
Vue.use(AlertPlugin);
const app = new Vue({
el: '#app',
render: h => h(Main)
});
当我尝试运行它时,网页变为空白,并且错误 AlertPlugin 未定义。
请帮忙?
【问题讨论】:
标签: javascript ecmascript-6 vue.js vuejs2 es6-modules