[Vuejs]-Vuejs โ€“ rendering class

1๐Ÿ‘

โœ…

Put the class object in the span element instead of the div element.

this.$Message.info({
  render: h => {
    return h("div", 
    [
      "This is created by ", 
      h("span", {class : "red" }, "render function ")
    ])
  }
});

Example :

Vue.config.devtools = false;
Vue.config.productionTip = false;

var app = new Vue({
  el: '#app',
  render: h => {
    return h("div", 
    [
      "This is created by ", 
      h("span", {class : "red" }, "render function ")
    ])
  }
})
.red {
  color:red;
  background:blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>

<div id="app">
</div>
๐Ÿ‘คPierre Said

0๐Ÿ‘

class should be an array, not a string:

h('div', {class: ['red']})

Vue docs

๐Ÿ‘คjarraga

Leave a comment