美文网首页
函数组件

函数组件

作者: 罗不错 | 来源:发表于2020-08-26 11:15 被阅读0次
    <template functional>
      <div class="book">
        {{props.book.name}} {{props.book.price}}
      </div>
    </template>
    
    <script>
    Vue.component('book', {
      functional: true,
      props: {
        book: {
          type: () => ({}),
          required: true
        }
      },
      render: function (createElement, context) {
        return createElement(
          'div',
          {
            attrs: {
              class: 'book'
            }
          },
          [context.props.book]
        )
      }
    })
    </script>
     
    

    相关文章

      网友评论

          本文标题:函数组件

          本文链接:https://www.haomeiwen.com/subject/wkyxsktx.html