我创建了一个自定义组件并注册了它。但我在浏览器中得到一个警告,我无法处理。在我看来,它是正确注册的吗?
vue.js:435 Vue警告:未知的自定义元素:-您正确注册了组件吗?对于递归组件,请确保提供"name“选项。 找到位置 ->
主
import GISView from './components/GISView.vue';
import VueEvents from 'vue-events';
window.Vue = Vue;
Vue.use(VueEvents)
var App = window.App = new Vue({
el: '#app',
components: {
'gisview': GISView
},
data() {
return {
eventData: {
foo: 'baz'
}
}
},
methods: {
init: function() {
this.$events.$emit("test", this.eventData);
}
}
});组件
<template>
<div ref="map" id="map" class="google-map" style="position: relative; overflow: hidden;">
<div style="height: 100%; width: 100%; position: absolute; top: 0px; left: 0px;">
<gisview></gisview>
</div>
</div>
</template>
<script>
import GoogleMaps from '../mixins/GoogleMaps.js';
export default {
mixins: [GoogleMaps],
mounted() {
console.log("Mounted");
this.$events.$on('test', eventData => console.log("Fired"));
},
data: function() {
return {
eventData: {
foo: 'baz'
}
}
},
methods: {
initMap: function() {
map = new google.maps.Map(this.$els.map, {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
}
}
</script>使用
<div class="wrapper wrapper-content animated fadeInRight">
<div id="app">
<div class="row">
<div class="col-md-7">
<div class="ibox">
<div class="ibox-title">GIS</div>
<div class="ibox-content">
<gisview></gisview>
</div>
</div>
</div>
</div>
</div>
</div>发布于 2017-05-10 15:26:53
我在这里看到了1-2个问题。
GISView到App.vue ,这意味着您只能在App.vue的模板中使用<gisview>。您可以像这样在全局注册GISView,但我怀疑您是否愿意这样做。Vue.component(GISView)
GISView.vue吗?如果是的话,您将尝试在其内部使用<gisview>。递归组件是一回事,但我不认为这是您想要的。https://stackoverflow.com/questions/43896620
复制相似问题