67 lines
1.4 KiB
Vue
67 lines
1.4 KiB
Vue
![]() |
|
|||
|
<!-- component标签可以变换组件 -->
|
|||
|
<template>
|
|||
|
<component :is="compUrl" :formData="formData" :history="history" :activeKey="activeKey" v-if="compUrl" @getStampSuc="getStampSuccess"></component>
|
|||
|
</template>
|
|||
|
<script setup lang="ts">
|
|||
|
import { ref, reactive, onMounted,computed, watch, nextTick } from 'vue';
|
|||
|
const compName = ref('');
|
|||
|
const compUrl = ref(null);
|
|||
|
|
|||
|
defineOptions({
|
|||
|
name: 'DynamicLink',
|
|||
|
options: {
|
|||
|
styleIsolation: 'shared',
|
|||
|
},
|
|||
|
})
|
|||
|
const props = defineProps({
|
|||
|
path: {
|
|||
|
type: String,
|
|||
|
default: ""
|
|||
|
},
|
|||
|
history: {
|
|||
|
type: String,
|
|||
|
default: ""
|
|||
|
},
|
|||
|
activeKey: {
|
|||
|
type: String,
|
|||
|
default: ""
|
|||
|
},
|
|||
|
formData: {
|
|||
|
type: Object,
|
|||
|
default: () => {},
|
|||
|
}
|
|||
|
|
|||
|
})
|
|||
|
// 监听 option 变化
|
|||
|
watch(() => props.path, (newVal) => {
|
|||
|
console.log(newVal)
|
|||
|
// if(newVal) compName.value = newVal;
|
|||
|
if(newVal) compName.value = 'pages-process/test';
|
|||
|
compUrl.value = defineAsyncComponent(() => import(`@/${compName.value}.vue`));
|
|||
|
}, {
|
|||
|
deep: true,
|
|||
|
// #ifdef MP-WEIXIN
|
|||
|
immediate: true
|
|||
|
// #endif
|
|||
|
});
|
|||
|
const comp = reactive({
|
|||
|
component:compUrl.value
|
|||
|
})
|
|||
|
|
|||
|
|
|||
|
const getStampSuccess=(val)=>{
|
|||
|
// this.$emit('getStampSuc', val)
|
|||
|
// //在<component>标签动态组件使用vuex,没有保存成功。
|
|||
|
// //所以先传出来再试一下
|
|||
|
// this.$store.commit("cache/setEsignTags", {
|
|||
|
// esignTag: val
|
|||
|
// });
|
|||
|
}
|
|||
|
|
|||
|
</script>
|
|||
|
|
|||
|
<style lang="scss" scoped>
|
|||
|
|
|||
|
</style>
|