一. render/h函数(了解)

 详见:https://v3.cn.vuejs.org/guide/render-function.html#dom-树

第十三节:Vue3高级之 render/h函数、jsx、自定义指令、teleport、插件

 

 

二. jsx(了解)

  Vue3.x版本创建的项目使用jsx已经不需要配置babel了。

 代码分享:

<script>
  import HelloWorld from './HelloWorld.vue';
  export default {
    data() {
      return {
        counter: 0
      }
    },
    render() {
      const increment = () => this.counter++;
      const decrement = () => this.counter--;
      return (
        <div>
          <h2>当前计数: {this.counter}</h2>
          <button onClick={increment}>+1</button>
          <button onClick={decrement}>-1</button>
          <HelloWorld>
          </HelloWorld>
        </div>
      )
    }
  }
</script>
View Code

相关文章:

  • 2022-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-29
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-09-08
猜你喜欢
  • 2021-07-18
  • 2022-02-05
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案