vue中鼠标右击菜单(rightmenu),以及回调处理

news/2024/7/10 3:20:47 标签: vue, rightmenu, 右击菜单, 回调处理

vuerightmenu_2">vue中鼠标右击菜单rightmenu),以及回调处理


安装和引用

使用案例

vue"><template>
    <div>
        <h3>24324</h3>
        <button v-rightMenu = "menudata"  @contextmenu.prevent="get(index)" v-for="(item,index) in 10">
            <p>{{text}}</p>
        </button>
    </div>
</template>
<script>
    export default {
        name:"demo",
        data(){
            return {
                text:'asdas',
                getindex:'1',
                menudata:{
                    // 菜单box的样式   Menu box style
                    boxStyle:"width:150px;background:#f55;",
                    // 菜单选项的样式 Style of menu options
                    optionStyle:"color:#fff;line-height:30px;font-size:15px;",
                    menus:[
                        {
                        /**
                         * content 菜单显示的文字 <支持html> 
                         * callback:菜单点击要触发函数  需要在methods定义 
                         * style : 本项菜单的单独样式 可以覆盖掉optionStyle  
                         * icon : icon图片地址
                         * iconStyle: icon 图片的样式(例如大小等 直接作用于图片)
                         * iconPosition : 支持left / right (其余全部按照left处理);
                         * content The text displayed on the menu(can use html)
                         * callback: Menu clicks to trigger functions need to be defined in methods
                         * style :  The single style of this menu can override option Style
                         * icon : your icon's url
                         * iconStyle : you icon's style ,is image's style
                         * iconPosition :you can use left or right ;The rest are all processed according to left
                         */
                        /**
                         * 字段(field)           类型(type)                 是否可以为空(is can null)    默认值
                         * content            [ html | text ]                       Y                   ""
                         * callback           [  methods function ]                 Y                   return false
                         * style                   [ css ]                          Y                   ""
                         * icon                   [ url ]                           Y                   ""
                         * iconStyle              [ css ]                           Y                   ""
                         * iconPosition           [string]                          Y                   "left"
                        */
                        content:"menu content",
                        callback:"callbackMethods",
                        style:"border-bottom:1px solid #fff;background:#333;line-height:30px;",
                        icon:"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2310514390,3580363630&fm=27&gp=0.jpg",
                        iconStyle:"width:20px;height:20px;",
                        iconPosition:"left",
                        },
                        {
                        content:"右键菜单二",
                        callback:"otherMethods"
                        }
                    ],
                },
            }
        },
        mounted() {
        },
        watch:{

        },
        methods:{
            get(index){
                this.getindex = index
            },
            callbackMethods(){
                // do something
                console.log(this.getindex)
            },
            otherMethods(){
                // do something
            }
        }
    }
</script>

效果展示

在这里插入图片描述


http://www.niftyadmin.cn/n/482798.html

相关文章

vue动态时间显示

vue动态时间显示 1. 封装date.js function showDate() {const date new Date();const yeardate.getFullYear();const monthdate.getMonth()1;const daydate.getDate();const hourdate.getHours();const mindate.getMinutes();const secdate.getSeconds();document.getElemen…

vue+NodeJS项目部署打包上线到阿里云完整版(前台vue,后台node)

vueNodeJS项目部署打包上线到阿里云完整版&#xff08;前台vue&#xff0c;后台node&#xff09; 阿里云服务器配置 购买云服务器&#xff0c;这里不做介绍。 改root密码&#xff1a; sudo passwd root 安装宝塔&#xff0c;执行一下命令 Centos&#xff1a;yum install -y …

校验电话号码自动生成标签(包含多个粘体复制生成标签)

校验电话号码自动生成标签 <template><div><!-- <label class"labelname">{{labelname}}</label> --><div class"inputbox"><div class"arrbox"><div v-for"(item, index) in labelarr"…

weex开发- 无法找到模块“weex-vue-render”的声明文件。引入vue报错,无法找到引入的vue模块

在引入了vuex之后编译报错&#xff0c;引入如下&#xff1a; 这是weex-dev生成的文件&#xff0c;里面可以明显看到无法找到声明文件 下面看这个js文件内容&#xff1a; 也没有什么特别的&#xff0c;但是在引入的时候&#xff0c;确偏偏报了无法找到模块的错误&#xf…

网页视频播放器(easyplayer和vue-video-player的使用)

网页视频播放器&#xff08;easyplayer和vue-video-player的使用&#xff09; 描述 两种方式实现的网页播放器支持的视频格式不太相同 安装插件 npm install easydarwin/easyplayer --savenpm install copy-webpack-plugin5.1.2 --save-devcnpm install --save videojs-cont…

weex开发 - 加载index.js崩溃,白屏(may it has been destroyed so method:fireEvent is ignored,Url must be passe)

最近&#xff0c;博主在做weex项目中发现了一个奇怪的问题&#xff0c;分别会报如下几个错误&#xff1a; 1.[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0] 2.<Weex>[info]WXBridgeContext.m:552, No sen…

weex开发 - 方法的映射,在weex调用fetch方法,实际调用同名的原生方法,在回调中把数据传递回js

方法的映射通过标题的解释也可以很明显的看出来&#xff0c;是通过在js上调用和原生同名的方法&#xff0c;在原生返回数据中把这些数据回传给JS的一种方法&#xff0c;这么做的原因是weex中的网络请求不能满足我们客户端网络安全和各种配置的需求。 具体的做法&#xff0c;首…

vue实现人员展示页面

vue实现人员展示页面 功能描述 实现人员展示实现无限滚动添加 display.vue <template><div class"display"><div class"displayBox"><header><span>人员展示页面</span></header><div class"displa…