MMF-FE / svgicon

SVG icon components and tool set
https://mmf-fe.github.io/svgicon
MIT License
922 stars 95 forks source link

icon not reactive when initialize with empty name #51

Closed r1m closed 6 years ago

r1m commented 6 years ago

Reactivity fails : If we create an icon with dynamic name with initial value set to an non existing id, it is not rendered when the name value change.


<template>
  <div>
    <svgicon
      :icon="name"
    />
    <button @click="changeIcon">Test</button>
  </div>
</template>
<script>
import svgicon from 'vue-svgicon';

export default {
  name: 'MyIcon',
  components: {
    svgicon,
  },
  data() {
    return { name: '' };
  },
  methods: {
    changeIcon() {
      this.name = 'icon';
    },
  },
};
</script>

If name is initialized with an existing icon name, it works.

r1m commented 6 years ago

My guess is that this line is the problem https://github.com/MMF-FE/vue-svgicon/blob/master/component/svgicon.vue#L62

loaded is only evaluated when the component is created