v-contextmenu - npm (npmjs.com)
npm i [email protected] --save-dev
npm install --save vue-runtime-helpers
# main.ts
import contentmenu from 'v-contextmenu'
import "v-contextmenu/dist/themes/bright.css";
# myTree.vue
<template>
<div class="wrap" v-contextmenu:contextmenu>
<v-contextmenu ref="contextmenu" theme="default">
<v-contextmenu-item>GitHub</v-contextmenu-item>
<v-contextmenu-item>GitLab</v-contextmenu-item>
<v-contextmenu-submenu title="蔬菜菜">
<v-contextmenu-item>土豆</v-contextmenu-item>
<v-contextmenu-submenu title="青菜">
<v-contextmenu-item>小油菜</v-contextmenu-item>
<v-contextmenu-item>空心菜</v-contextmenu-item>
</v-contextmenu-submenu>
<v-contextmenu-item>黄瓜</v-contextmenu-item>
</v-contextmenu-submenu>
<v-contextmenu-item disabled>菠萝蜜</v-contextmenu-item>
<v-contextmenu-divider />
<v-contextmenu-item>哈密瓜</v-contextmenu-item>
<v-contextmenu-item @click="handleUserManagement">
<StepBackwardOutlined />
<span>用户管理</span>
</v-contextmenu-item>
</v-contextmenu>
</div>
</template>
<script lang="ts" setup>
import {
StepBackwardOutlined,
} from '@ant-design/icons-vue';
import {message} from 'ant-design-vue';
const handleUserManagement = () => {
message.success('用户管理');
};
</script>
<style scoped>
.wrap {
display: flex;
justify-content: center;
align-items: center;
width: 300px;
height: 200px;
border: 3px dashed rgba(90, 167, 164, 0.9);
border-radius: 8px;
background-color: rgba(90, 167, 164, 0.2);
}
</style>
参考:
https://juejin.cn/post/7263042106440695865?from=search-suggest
https://juejin.cn/post/7250513276236267557?from=search-suggest
https://juejin.cn/post/7001837920772423716?from=search-suggest牛
http://ashuai.work:8888/#/selectDown牛
https://segmentfault.com/a/1190000043003687
https://layui.dev/docs/2/util/#api
https://cybernika.net/v-contextmenu/
标签:vue,contextmenu,https,juejin,import,com From: https://www.cnblogs.com/DQ-MINE/p/17995259