JavaScript
扫一扫 标签描述

本文介绍如何在vue中定义插件,注册插件和使用插件 插件目录 /src/plugins 插件入口文件 /src/plugins/index.js importcachefrom'./cache' importmodalfrom'./modal' //安装默认插件,在main.js中引入,通过Vue.use()使用它,因为index.js里使用exportdefault导出,所有在main.js里导入时可以不用加{},直接importpluginsfrom"/plugins"; exportdefault{ install(Vue){ //缓存对象 Vue.prototype.$cache=c...