我正在尝试使用 vue-social-sharing 但出现此错误 [nuxt] 应用程序初始化期间捕获错误 TypeError: 无法设置未定义的属性(设置 '$SocialSharing')
`从“vue-social-sharing”导入VueSocialSharing;
导出默认的defineNuxtPlugin(({vueApp}) => { vueApp.use(VueSocialSharing)
your text
});`
确保您使用的是 Vue 3 模块
npm install --save vue-social-sharing@next
~/plugins/social-sharing.ts
import VueSocialSharing from 'vue-social-sharing'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueSocialSharing)
})
组件使用示例。
<template>
<div>
<ClientOnly>
<ShareNetwork
network="twitter"
url="http://localhost:3000"
title="Say hi to Vite! A brand new, extremely fast development setup for Vue."
description="This week, I’d like to introduce you to 'Vite', which means 'Fast'. It’s a brand new development setup created by Evan You."
quote="The hot reload is so fast it\'s near instant. - Evan You"
hashtags="vuejs,vite,javascript"
twitterUser="youyuxi"
>
<i class="fab fah fa-lg fa-twitter"></i>
<span>Share on Twitter</span>
</ShareNetwork>
</ClientOnly>
</div>
</template>