feat(runtime): vue2 h传参与vue3不一样,需要自定义render

This commit is contained in:
roymondchen 2025-02-27 19:32:48 +08:00
parent 91cde30d75
commit 90abde57cc
2 changed files with 10 additions and 0 deletions

View File

@ -19,6 +19,7 @@
import Vue from 'vue';
import TMagicApp, { DataSourceManager, DeepObservedData, getUrlParam, registerDataSourceOnDemand } from '@tmagic/core';
import type { userRenderFunctionOptions } from '@tmagic/vue-runtime-help';
import asyncDataSources from '../.tmagic/async-datasource-entry';
import components from '../.tmagic/comp-entry';
@ -64,6 +65,10 @@ registerDataSourceOnDemand(dsl, asyncDataSources).then((dataSources) => {
const vueApp = new Vue({
provide: {
app,
userRender: ({ h, type, props, attrs, style, className }: userRenderFunctionOptions) =>
// class作为保留字符android 4.4以下不能直接使用, 需要加引号
// eslint-disable-next-line prettier/prettier
h(type, { props, attrs, style, 'class': className }),
},
render: (h) => h(AppComponent),

View File

@ -19,6 +19,7 @@
import Vue from 'vue';
import TMagicApp, { DataSourceManager, DeepObservedData } from '@tmagic/core';
import type { userRenderFunctionOptions } from '@tmagic/vue-runtime-help';
import App from './App.vue';
@ -61,6 +62,10 @@ Promise.all([
render: (h) => h(App),
provide: {
app,
userRender: ({ h, type, props, attrs, style, className }: userRenderFunctionOptions) =>
// class作为保留字符android 4.4以下不能直接使用, 需要加引号
// eslint-disable-next-line prettier/prettier
h(type, { props, attrs, style, 'class': className }),
},
el: '#app',
});