尝试使用vue-社会化共享(最新版本2.4.3)库,但始终获得以下内容:
Vue警告:未知的自定义元素:-您正确注册了组件吗?对于递归组件,请确保提供"name“选项.。
我遵循了指南中的代码示例。但是,似乎找不出我错过了什么或者说错了什么。
我创建了一个单独的组件,并遵循了vue-社会化共享提供的示例。但仍然不断地犯错误。
这是我的main.js:
import Vue from 'vue'
import './plugins/vuetify'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false;
let SocialSharing = require('vue-social-sharing');
Vue.use(SocialSharing);
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app');以下是我的组件(SocialSharingTest.vue):
<template>
<social-sharing url="https://vuejs.org/"
title="The Progressive JavaScript Framework"
description="Intuitive, Fast and Composable MVVM for building interactive interfaces."
quote="Vue is a progressive framework for building user interfaces."
hashtags="vuejs,javascript,framework"
twitter-user="vuejs"
inline-template>
<div>
<network network="email">
<i class="fa fa-envelope"></i> Email
</network>
<network network="facebook">
<v-icon class="mr-3" style="color: #3b5998">fab fa-facebook</v-icon>
</network>
<network network="googleplus">
<i class="fa fa-google-plus"></i> Google +
</network>
</div>
</social-sharing>
</template>
<script>
export default {
name: "SocialSharingTest",
}
</script>
<style scoped>
</style>组件没有像预期的那样工作,并一直得到上面描述的**Vue警告。我在这里看到了一个我希望看到的例子:
发布于 2019-05-26 16:48:17
import SocialSharing from 'vue-social-sharing';
import Vue from 'vue'
const VueSelect = {
install(Vue, options) {
Vue.component('SocialSharing', SocialSharing)
}
};
Vue.use(VueSelect)你能试试这个看看是否管用吗?
发布于 2019-05-26 15:52:44
这是如何在全球注册组件的方式:
const SocialSharing = require('vue-social-sharing');
Vue.component('social-sharing', SocialSharing)发布于 2019-05-26 17:26:40
我还开始在这个组件上接收一个Vue警告:未知的自定义元素:v图标(而不是在其他使用v图标的组件中)。为了将其修复到我的main.js中,我添加了以下内容:
const Vuetify = require('vuetify');
Vue.use(Vuetify);但是现在试图将社交共享整合到我已经创建的组件中,这给了我Vue警告:未能挂载组件:模板或呈现函数未定义。。
还没调查那么多。可能和Vuetify有关(我想把它包括进去?)我会继续挖掘那里正在发生的事情,但如果有人知道会发生什么,我会接受任何帮助。
谢谢。只是为了澄清上面的工作,原来的问题。它似乎都在自己的组件中工作,只是在尝试将其合并到我希望使用的组件中时不像我所期望的那样工作。
inline-template UPDATE --我只是在我的社交共享标签中不包括:
<social-sharing url="https://vuejs.org/" inline-template>https://stackoverflow.com/questions/56315039
复制相似问题