sherwinshen/vue3-text-clamp

How use in Nuxt 3?

Opened this issue · 2 comments

Please tell me how to use this component in Nuxt3.js?
I am trying to use the component locally according to the manual:

<template>
  <text-clamp text='hello world' :max-lines='2' />
</template>
<script lang='ts' setup>
import TextClamp from 'vue3-text-clamp';
</script>

but I get an error:
TypeError: Cannot read properties of undefined (reading 'defineComponent')
at file:///********/node_modules/vue3-text-clamp/lib/text-clamp.js:1:370

Hi, for temporary fix i copy text-clamp.vue from repo to my components folder and use as usual.

<ClientOnly>
  <ClampText :max-lines="2" :text="material.description" />
</ClientOnly>

Hi,

Create a file inside the plugins folder called text-clamp.client.ts with the following contents:

import TextClamp from 'vue3-text-clamp'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(TextClamp)
})