Git Product home page Git Product logo

svg-vue3's People

Contributors

danielstgt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

amit-soni7

svg-vue3's Issues

Icon prop is not reactive

Hi,

Let's say we have a template like this

<SvgVue :icon="icon" />

where the icon is a dynamic value.

Now only the initial value applies.

Works with these changes:

const iconPath = computed(() => props.icon.replace(new RegExp('.'.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'), 'g'), '/') + '.svg');

const svgString = computed(() => require(`svg-files-path/${iconPath.value}`).default);
const svgViewBoxValues = computed(() => svgString ? (/viewBox="([^"]+)"/.exec(svgString.value) || '')[1] : null);
const svgContent = computed(() => svgString ? svgString.value.replace(/^<svg[^>]*>|<\/svg>$/g, '') : null);

https://github.com/danielstgt/svg-vue3/blob/master/src/svg-vue.vue#L21

Of course, there is a workaround:

<SvgVue :icon="icon" :key="icon" />

But can you explain, please, if there are any reasons (performance-wise?) to not make it reactive?

The same for the component for Vue 2, I use both on different projects.

ReferenceError: document is not defined

Hello there,

I'm using https://github.com/danielstgt/laravel-mix-svg-vue and it works well (thanks)

But in SSR mode (Laravel + Inertia) I have the following error

[Vue warn]: Unhandled error during execution of render function 
  at <SvgVue icon="add" class="w-3 mr-2" >
ReferenceError: document is not defined
    at ReactiveEffect.fn (/var/www/html/node_modules/svg-vue3/dist/svg-vue.ssr.js:69:21)
    at ReactiveEffect.run (/var/www/html/node_modules/@vue/reactivity/dist/reactivity.cjs.js:150:25)
    at ComputedRefImpl.get value [as value] (/var/www/html/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1090:39)
    at unref (/var/www/html/node_modules/@vue/reactivity/dist/reactivity.cjs.js:998:29)
    at Object.get (/var/www/html/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1001:37)
    at Proxy.render (/var/www/html/node_modules/svg-vue3/dist/svg-vue.ssr.js:87:72)
    at renderComponentRoot (/var/www/html/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:887:44)
    at renderComponentSubTree (/var/www/html/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:275:51)
    at renderComponentVNode (/var/www/html/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:214:16)
    at renderVNode (/var/www/html/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:310:22)

I'm wondering why document is called in an ssr file?

Thanks for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.