Vue.component注意事项

本文解析了在使用Vue.js框架时,直接使用new关键字进行组件注册的常见错误,并解释了为何这种做法会导致Uncaught TypeError错误。文章强调了正确的Vue组件注册方式,避免因误用new关键字而引发的问题。
Vue.component前不要加 new,否则报错:

Uncaught TypeError: Cannot read property '_base' of undefined

转载于:https://www.cnblogs.com/wanlibingfeng/p/9685254.html

import Vue from 'vue' import VueRouter from 'vue-router' import VueResource from 'vue-resource' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import router from './router/router' import BaiduMap from 'vue-baidu-map' import VueQuillEditor from 'vue-quill-editor' import 'quill/dist/quill.core.css' import 'quill/dist/quill.snow.css' import 'quill/dist/quill.bubble.css' import '@/assets/css/iconfont.css' import config from './config/config' import validate from './common/validate' import VueAMap from 'vue-amap' Vue.component('aplayer', APlayer) // 后台地图 Vue.use(VueAMap) VueAMap.initAMapApiLoader({ //key: 'ca04cee7ac952691aa67a131e6f0cee0', key: '001d42eaa139dc53fd655e7c23c0187e', plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'AMap.Geocoder','AMap.CitySearch'], // 默认高德 sdk 版本为 1.4.4 v: '1.4.4' }) import { isAuth, getCurDateTime, getCurDate, isBackAuth, } from './common/system' import App from './App.vue' import Breadcrumb from '@/components/Breadcrumb' import FileUpload from '@/components/FileUpload' import Editor from "@/components/Editor"; import aplayer from 'vue-aplayer'; import store from './store' import { encryptDes,decryptDes,encryptAes,decryptAes } from '@/common/des.js' import VueLuckyCanvas from '@lucky-canvas/vue' Vue.use(VueLuckyCanvas) Vue.config.productionTip = false; Vue.prototype.$config = config; Vue.prototype.$validate = validate; Vue.prototype.isAuth = isAuth; Vue.prototype.isBackAuth = isBackAuth; Vue.prototype.getCurDateTime = getCurDateTime; Vue.prototype.getCurDate = getCurDate; Vue.prototype.encryptDes = encryptDes Vue.prototype.decryptDes = decryptDes Vue.prototype.encryptAes = encryptAes Vue.prototype.decryptAes = decryptAes Vue.use(VueRouter); Vue.use(VueResource); Vue.use(ElementUI); Vue.use(BaiduMap, {}); Vue.use(VueQuillEditor); Vue.component('Breadcrumb', Breadcrumb); Vue.component('file-upload', FileUpload); Vue.component('editor', Editor); Vue.component('aplayer', aplayer); Vue.http.options.root = config.name; Vue.http.headers.common['Token'] = localStorage.getItem('frontToken'); Vue.http.interceptors.push(function(request, next) { next((response) => { if (response.data.code == 401 || response.data.code == 403) { this.$message.error('请先登录') setTimeout(()=>{ this.$router.replace('/login').catch(err => {}); localStorage.clear() },1000) } else { return response; } }); }); router.afterEach((to, from) => { if (from.path == '/login') { Vue.http.headers.common['Token'] = localStorage.getItem('frontToken'); } }) new Vue({ render: h => h(App), router, store, }).$mount('#app')报错APlayer is not defined ReferenceError: APlayer is not defined at eval (webpack-internal:///./src/main.js:54:66) at ./src/main.js (http://localhost:8082/js/app.js:2925:1) at webpack_require (http://localhost:8082/js/app.js:5940:32) at http://localhost:8082/js/app.js:7087:96 at webpack_require.O (http://localhost:8082/js/app.js:5988:23) at http://localhost:8082/js/app.js:7088:53 at http://localhost:8082/js/app.js:7090:12
最新发布
09-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值