|
|
@ -1,11 +1,41 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<!-- 添加图标替换文字 -->
|
|
|
|
收缩图标
|
|
|
|
<el-icon style="cursor: pointer" :size="26" @click="iconClick">
|
|
|
|
</div>
|
|
|
|
<!-- <Expand /> -->
|
|
|
|
|
|
|
|
<!-- 使用动态组件 -->
|
|
|
|
|
|
|
|
<!-- currentTab 改变时组件也改变 -->
|
|
|
|
|
|
|
|
<component :is="status ? Expand : Fold"></component>
|
|
|
|
|
|
|
|
</el-icon>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
// 已经全局引入图标,不需要单独引入
|
|
|
|
|
|
|
|
// 切换至使用动态组件,此时需要局部引入
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Expand, Fold } from '@element-plus/icons-vue';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 引入computed
|
|
|
|
|
|
|
|
import { computed } from 'vue'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 引入useCollapseStore
|
|
|
|
|
|
|
|
import { useCollapseStore } from '@/store/collapse';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取store
|
|
|
|
|
|
|
|
const store = useCollapseStore()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取状态
|
|
|
|
|
|
|
|
const status = computed(()=>{
|
|
|
|
|
|
|
|
return store.getcollapse
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 给图标添加点击事件
|
|
|
|
|
|
|
|
const iconClick = ()=>{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 通过取反collapse管理图标的状态值
|
|
|
|
|
|
|
|
store.collapse = (!store.collapse)
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
<style scoped>
|
|
|
|