欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue如何解決循環(huán)引用組件報(bào)錯(cuò)的問(wèn)題

 更新時(shí)間:2018年09月22日 11:31:50   作者:666888  
這篇文章主要介紹了vue如何解決循環(huán)引用組件報(bào)錯(cuò)的問(wèn)題,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

問(wèn)題由來(lái)

最近在做項(xiàng)目的時(shí)候遇到使用循環(huán)組件,因?yàn)槟J揭粯樱挥袛?shù)據(jù)不一樣。按照普通組件調(diào)用格式來(lái)做的時(shí)候總是報(bào)錯(cuò),錯(cuò)誤信息為[Vue warn]: Unknown custom element: <selfile> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

解決方案

查詢了網(wǎng)上各種資料之后,發(fā)現(xiàn)是循環(huán)調(diào)用組件時(shí),組件比vue實(shí)例后創(chuàng)建,官方文檔里寫組件必須先于實(shí)例化引入,所以說(shuō)組件沒(méi)有正確的引入。

解決方式

解決的方式就是全局引入組件,并且在vue實(shí)例化前。

具體到我們項(xiàng)目中,就是在main.js里引入。

具體代碼如下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/>'
})

用上面的方法全局引入組件就可以解決循環(huán)引用組件報(bào)錯(cuò)的問(wèn)題。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論