Home > Article > Web Front-end > What to do if there is an error when circularly referencing components in vue.js
The solution to the error of circular reference components in vue.js: introduce global components in [main.js], the code is [import Axios from './utils/axiosPlugin'].
【Recommended related articles: vue.js】
The solution to the error of circular reference component in vue.js:
Solution
Query After reading various information on the Internet, I found that when the component is called cyclically, the component is created after the vue instance. The official document states that the component must be introduced before instantiation, so the component is not introduced correctly.
Solution
The solution is to introduce the component globally and before vue is instantiated.
Specifically in our project, it is introduced in main.js.
The specific code is as follows main.js:
import Vue from 'vue' import App from './App' import router from './router' import store from './store'; import iView from 'iview'; import './styles/index.less' import {VTable,VPagination} from 'vue-easytable' import 'vue-easytable/libs/themes-base/index.css' import Axios from './utils/axiosPlugin' import './styles/button.css' import './styles/common.css' // require('./mock/mock') import selFile from './views/file/selFile.vue' Vue.use(iView); Vue.use(Axios); Vue.component(VTable.name, VTable) Vue.component(VPagination.name, VPagination) Vue.component("selFile",selFile) Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', store, router, components: { App }, template: '<App/>' })
Related free learning recommendations: JavaScript (video)
The above is the detailed content of What to do if there is an error when circularly referencing components in vue.js. For more information, please follow other related articles on the PHP Chinese website!