Javascript 如何解决“vue警告”的问题;名称“;重新创建组件的选项
我在@vue/cli应用程序的控制台中遇到此错误。该应用程序可以在浏览器上运行,但axios get(从其他网站获取)未显示,我收到此错误。 它是以我的vue的名义出现的,还是我的项目中的其他内容Javascript 如何解决“vue警告”的问题;名称“;重新创建组件的选项,javascript,vue.js,vue-component,vue-cli,Javascript,Vue.js,Vue Component,Vue Cli,我在@vue/cli应用程序的控制台中遇到此错误。该应用程序可以在浏览器上运行,但axios get(从其他网站获取)未显示,我收到此错误。 它是以我的vue的名义出现的,还是我的项目中的其他内容 > Unknown custom element: <country-card> - did you register the component correctly? For recursive components, make sure to provide the "
> Unknown custom element: <country-card> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
> found in
>
> ---> <CountryList> at src/components/CountryList.vue
<App> at src/views/SearchCountry.vue
<App> at src/App.vue
<Root>
>未知自定义元素:-您是否正确注册了组件?对于递归组件,请确保提供“name”选项。
>发现于
>
>-->src/components/CountryList.vue上
在src/views/SearchCountry.vue上
在src/App.vue
我的大部分页面都已加载,但axios无法加载。
这是muCountryList.vue的代码
<template>
<div class="country-layout">
<country-card v-for="country in countryList" :key="country.name" :country="country"></country-card>
</div>
</template>
<script>
//import card vue detaisl
import CountryPlate from "./CountryPlate";
//import axios
import axios from "axios";
export default {
name: "CountryList",
components: {
CountryPlate
},
//countrylist array initilaized for use
data() {
return {
countryList: []
};
},
//gets all values and populates to tis
mounted() {
this.getAll();
},
//get search value from user and places it in getcountries function as value store
watch: {
searchValue() {
this.getCountries(this.searchValue)
}
},
props: ["searchValue", "region"],
methods: {
getAll(){
//getall frunction uses axios to get site info then places it coutrylist from the response event
axios
.get("https://restcountries.eu/rest/v2/all")
.then(response => {
this.countryList = response.data;
})
.catch(error => {
//handle the error
console.log(error)
});
},
getCountries() {
//get axios as a function
axios
//get api result + seacrch value from user
.get("https://restcountries.eu/rest/v2/all" + this.searchValue)
//getCountries places info in reponse whic is in countryList array. and fills it if logial operator for region
// is used and fullfiled being the right region ana ALL regiosn
.then(response => {
this.countryList = [];
response.data.foreach(e => {
if (e.region === this.region || this.region === "All") {
this.countryList.push(e);
}
});
}).catch(error => {
this.countryList = []
})
}
},
}
</script>
<style>
.country-layout {
display: flex;
flex-wrap: wrap;
}
</style>
//导入卡vue detaisl
从“/CountryPlate”导入CountryPlate;
//导入axios
从“axios”导入axios;
导出默认值{
姓名:“国家名单”,
组成部分:{
乡牌
},
//已初始化以供使用的countrylist数组
数据(){
返回{
国家名单:[]
};
},
//获取所有值并填充到tis
安装的(){
这个。getAll();
},
//从用户处获取搜索值,并将其作为值存储放在getcountries函数中
观察:{
searchValue(){
this.getCountries(this.searchValue)
}
},
道具:[“搜索值”,“区域”],
方法:{
getAll(){
//getall frunction使用axios获取站点信息,然后将其放置在响应事件的coutrylist中
axios
.get(“https://restcountries.eu/rest/v2/all")
。然后(响应=>{
this.countryList=response.data;
})
.catch(错误=>{
//处理错误
console.log(错误)
});
},
getCountries(){
//获取axios作为函数
axios
//从用户处获取api结果+搜索值
.get(“https://restcountries.eu/rest/v2/all“+this.searchValue)
//getCountries将信息放置在countryList数组中的响应中。如果区域的逻辑运算符为,则填充该信息
//已使用且完整归档为所有区域的正确区域n
。然后(响应=>{
this.countryList=[];
response.data.foreach(e=>{
如果(e.region==this.region | | this.region===All){
这个.countryList.push(e);
}
});
}).catch(错误=>{
this.countryList=[]
})
}
},
}
.国家布局{
显示器:flex;
柔性包装:包装;
}
错误非常明显,国家/地区卡已注册。您可能需要以与导入CountryPlate相同的方式导入它