Skip to content

Commit

Permalink
feat(view): ✨ 使用 vue 3.3 defineOptions 宏声明单文件 name 属性,移除 vite-plugin-…
Browse files Browse the repository at this point in the history
…vue-setup-extend 插件
  • Loading branch information
xiangshu233 committed Dec 28, 2023
1 parent 7817f83 commit 56ae760
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"vite-plugin-html": "^3.2.1",
"vite-plugin-mock": "^2.9.8",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vite-plugin-windicss": "^1.9.3",
"vue-eslint-parser": "^9.3.2",
"vue-tsc": "^1.8.27"
Expand Down
5 changes: 2 additions & 3 deletions src/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
keep-alive 标签的 include 属性是根据组件的 name 判断的,
所以 index.vue 和 list.vue 等页面 vue 文件里一定要写上 name,
并且与 router 路由表中使用的 name 属性 一致,否则无效
本项目使用了 vite-plugin-vue-setup-extend 插件
可直接在 script 标签上书写 name 如:
<script setup lang="ts" name="DashboardPage">
Vue 3.3 中新引入了 defineOptions 宏声明 name 属性
https://gist.github.com/sxzz/3995fc7251567c7c95de35f45539b9c2
-->
<keep-alive v-if="keepAliveComponents" :include="keepAliveComponents">
<component :is="Component" :key="route.fullPath" />
Expand Down
6 changes: 5 additions & 1 deletion src/views/dashboard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
</div>
</template>

<script setup lang="ts" name="DashboardPage">
<script setup lang="ts">
import { computed } from 'vue';
import { useDesignSettingStore } from '@/store/modules/designSetting';
import SvgIcon from '@/components/SvgIcon.vue';
import { useGlobSetting } from '@/hooks/setting';
defineOptions({
name: 'DashboardPage',
});
const designStore = useDesignSettingStore();
const globSetting = useGlobSetting();
Expand Down

1 comment on commit 56ae760

@M69W
Copy link

@M69W M69W commented on 56ae760 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature 分支
已删插件却还在使用 vite-plugin-vue-setup-extend

import vueSetupExtend from 'vite-plugin-vue-setup-extend';

Please sign in to comment.