zoukankan      html  css  js  c++  java
  • 关于iview下拉菜单无法添加点击事件的解决办法

    效果如下图所示,点击下拉菜单,点击退出,然后跳到登录界面

     代码如下:

    <Dropdown trigger="click" style="margin-left: 20px;">
        <Avatar src="https://i.loli.net/2017/08/21/599a521472424.jpg" />
        <DropdownMenu slot="list">
             <DropdownItem  @click="isAdminModal = true">修改密码</DropdownItem>
             <DropdownItem  @click="logOut" divided>退出</DropdownItem>
        </DropdownMenu>
    </Dropdown>
                      

    方法如下:

    logOut() {
                this.$axios.get("api/api/netflow/v1/xky/logout")
                .then(res => {
                    console.log(res)
                    const code = res.data.code
                    // console.log(code)
                    if(code == '0000'){
                        this.$Notice.success({
                            desc: '登出成功!'
                        })
                        this.$router.push('/')
                    }
                    else {
                        this.$Notice.error({
                            title: '登出失败',
                            desc: res.data.errMsg
                        })
                    }
                    
                })
                .catch( error => {
                    console.log(error.response)
                    console.log(error.message)
                    this.$Notice.error({
                        desc: '登出失败!'
                    })
                })
            },

     然后没有打印????postman也测试通过了,那是为啥

    最后发现还是iview的坑啊,哭了,文档里写着点击事件,还有on-click都试了,没用,最后才知道需要加个修饰符.native,真的崩溃

    如下:

    <DropdownItem  @click.native="isAdminModal = true">修改密码</DropdownItem>
    <DropdownItem  @click.native="logOut" divided>退出</DropdownItem>

     问题解决,res也能正常返回了

  • 相关阅读:
    LeetCode:Plus One
    LeetCode:Text Justification
    LeetCode:Sqrt(x)
    LeetCode:Climbing Stairs(编程之美2.9-斐波那契数列)
    LeetCode:Simplify Path
    LeetCode:Edit Distance
    LeetCode:Set Matrix Zeroes
    LeetCode:Search in Rotated Sorted Array I II
    LeetCode:Search a 2D Matrix
    LeetCode:Sort Colors
  • 原文地址:https://www.cnblogs.com/SaberInoryKiss/p/11818567.html
Copyright © 2011-2022 走看看