这是我的iview Message
函数,用于呈现弹出消息。
this.$Message.info({
render: h => {
return h('div', {class:"red"}, [
'This is created by ',
h('span', 'render'),
' function'
])
}
});
CSS
.red{
color:red;
background:blue;
}
但是,我需要为span
而不是整个div
渲染一个类。
仅渲染span
的任何方法吗?
答案 0 :(得分:1)
将class
对象而不是span
元素放在div
元素中。
this.$Message.info({
render: h => {
return h("div",
[
"This is created by ",
h("span", {class : "red" }, "render function ")
])
}
});
示例:
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>