Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 哪个函数负责在vue.js的渲染引擎中渲染DOM?_Javascript_Vue.js - Fatal编程技术网

Javascript 哪个函数负责在vue.js的渲染引擎中渲染DOM?

Javascript 哪个函数负责在vue.js的渲染引擎中渲染DOM?,javascript,vue.js,Javascript,Vue.js,以vue 2.1.9为例。 链接: 你们知道哪个函数渲染DOM吗?你们可以创建一个渲染函数。请参阅下面的代码 Vue.component('anchored-heading', { render: function (createElement) { return createElement( 'h' + this.level, // tag name this.$slots.default // array of children ) },

以vue 2.1.9为例。 链接: 你们知道哪个函数渲染DOM吗?

你们可以创建一个渲染函数。请参阅下面的代码

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'
  ]
)

请参阅以了解更多信息。

\u渲染可能?它不是createElm吗?