N
N
Nikita Kit2018-03-27 02:41:23
Pug
Nikita Kit, 2018-03-27 02:41:23

Why doesn't the v-html directive work?

I want to display the svg markup of the icon inside the block created in the component, to which I deliver this icon via props.

<script>
  var Vue = require("vue/dist/vue.js");
  vHeader = Vue.component("vheader", {
    props: ['icons'],
    created: function(){
      console.log(this.$props);
    }
  });
  module.exports = vHeader;
</script>
<template>
  <header class='header'>
    <div class='plate row row--center-y row--between-x'>
      <div class='header__logo' v-html='icons.projectMenu'></div>
    </div>
  </header>
</template>

There are props in Vue DevTools, output to the console when in the created callback - also there. But it doesn't render to the page. There are no errors either in the terminal or in the browser. Instance code (careful - coffee. I'm awake at 5 am):
Vue = require "vue/dist/vue.js"
axios = require 'axios'
class VueEntry
  init: ->
    new Vue 
      el: "#vhead"
      data: ->
        return "icons": {}
      components: 
        "vheader": require("./header/header.vue")
      created: ->
        that = this
        axios.get('/jsondata/etc/icons.json')
          .then (resp) ->
            Object.assign that.$data.icons, resp.data
          .catch (err) ->
            console.log err


module.exports = VueEntry

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2018-03-27
@deworkers

I don't quite understand how it works for you, but I'll tell you for sure. New parameters added to the object are not reactively tracked. More details here
. Alternatively, receive data by promise

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question