vue3(setup),现在有一个组件是这样的:
[HTML] 纯文本查看 复制代码 <template>
<div :class="[focusChart === name ? 'fixed top-0 left-0 right-0 bottom-0 w-screen h-screen z-30' : '', bodyClass]">
<div v-if="focusChart === name" class="flex">
<el-button link :icon="Back" @click="$emit('closeFocus')">返回</el-button>
<span class="flex-1 font-bold h-10 flex justify-center items-center">聚集模式</span>
</div>
<slot />
</div>
</template>
<script setup>
import { Back } from '@element-plus/icons-vue';
defineProps(['name', 'title', 'bodyClass', 'focusChart'])
</script>
我这样调用:
[HTML] 纯文本查看 复制代码 <template>
<myChart bodyClass="w-1/2 h-full flex flex-col px-6 bg-white" name="ZT_TouSuZaiTu" :focusChart="focusChart" title="聚集模式"
@close-focus="focusChart = ''">
<div @dblclick="focusChart = 'ZT_TouSuZaiTu'" :ref="getDomRef('ZT_TouSuZaiTu')" class="flex-1 w-full h-full" />
</myChart>
</template>
<script setup>
import { ref, reactive, watch, onMounted } from 'vue';
import myChart from '@/common/components/myChart.vue';
const chartsOptions = {
ZT_ZhiYuan: ''
};
const focusChart = ref(''),
domChart = reactive({}),
charts = {};
Object.keys(chartsOptions).forEach(chart => {
domChart[chart] = ref(null);
});
const getDomRef = (name) => (el) => (domChart[name] = el);
onMounted(async () => {
});
</script>
但使用插槽会增加组件调用的复杂性,是否可以不使用插槽实现这个组件原有的功能? |