如何Vue.$compile在 Vue 3 运行时中使用编译函数?我在Vue 2中使用该函数。例如:
Vue.compile('<custom-component />');
Run Code Online (Sandbox Code Playgroud)
import {compile} from "vue"
compile('<custom-component />')
Run Code Online (Sandbox Code Playgroud)
仅此而已,几乎一样!
然后你可以做
render() {
return h({render: compile('<custom-component />')})
}
Run Code Online (Sandbox Code Playgroud)
一旦您无法指定模板的导入,如果它包含自定义组件,则它们必须事先在启动时使用 app.component 函数注册:vuejs.org/api/application.html#app-component
| 归档时间: |
|
| 查看次数: |
5401 次 |
| 最近记录: |