小编Art*_*miy的帖子

Vue3 在单击按钮时以编程方式创建组件实例

在 vue2 中很容易:

<template>
 <button :class="type"><slot /></button>
</template>
<script>
 export default {
   name: 'Button',
   props: [ 'type' ],
 }
</script>
Run Code Online (Sandbox Code Playgroud)
import Button from 'Button.vue'
import Vue from 'vue'

var ComponentClass = Vue.extend(Button)
var instance = new ComponentClass()

instance.$mount() // pass nothing
this.$refs.container.appendChild(instance.$el)
Run Code Online (Sandbox Code Playgroud)

扩展 + 创建实例。但是在 vue3 中它已被删除。哪里有别的办法?

javascript vue.js vuejs3

8
推荐指数
1
解决办法
2440
查看次数

标签 统计

javascript ×1

vue.js ×1

vuejs3 ×1