sherwinshen / vue3-text-clamp

📄 Vue3 component which allows you to ellipsis your multiline text
https://sherwinshen.github.io/vue3-text-clamp
MIT License
36 stars 6 forks source link

How use in Nuxt 3? #9

Open lna1989 opened 7 months ago

lna1989 commented 7 months ago

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

waitstop commented 4 months ago

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>
ptdev commented 1 month ago

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)
})