2019-09-16 - Vue - 渲染函数&JSX

源自:https://cn.vuejs.org/v2/guide/index.html

render: function (createElement) { return createElement('h1', this.blogTitle)}

createElement 参数

// @returns {VNode}

createElement(

    // {String | Object | Function}

     // 一个 HTML 标签名、组件选项对象,或者

    // resolve 了上述任何一种的一个 async 函数。必填项。

     'div',

    // {Object}  // 一个与模板中属性对应的数据对象。可选。

// {String | Array}

 // 子级虚拟节点 (VNodes),由 `createElement()` 构建而成,

// 也可以使用字符串来生成“文本虚拟节点”。可选。

[

    '先写一些文字',

    createElement('h1', '一则头条'),

    createElement(MyComponent, { props: { someProp: 'foobar' } })

])

使用JavaScript代替模板功能:。。。

你可能感兴趣的:(2019-09-16 - Vue - 渲染函数&JSX)