0
让我们来看看2.1.9。
链接:https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.9/vue.js 你们知道哪个函数呈现DOM吗?哪个函数负责渲染引擎中的vue.js中的DOM?
让我们来看看2.1.9。
链接:https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.9/vue.js 你们知道哪个函数呈现DOM吗?哪个函数负责渲染引擎中的vue.js中的DOM?
你总是可以创建一个render
函数。请参阅下面的代码。
Vue.component('anchored-heading', {
render: function (createElement) {
return createElement(
'h' + this.level, // tag name
this.$slots.default // array of children
)
},
props: {
level: {
type: Number,
required: true
}
}
})
这里createElement
是一个函数,如下所示。
// @returns {VNode}
createElement(
// {String | Object | Function}
// An HTML tag name, component options, or function
// returning one of these. Required.
'div',
// {Object}
// A data object corresponding to the attributes
// you would use in a template. Optional.
{
// (see details in the next section below)
},
// {String | Array}
// Children VNodes. Optional.
[
createElement('h1', 'hello world'),
createElement(MyComponent, {
props: {
someProp: 'foo'
}
}),
'bar'
]
)
欲了解更多信息,请参阅this post。
'_render'也许? – ste2425
是不是createElm? –