美文网首页
VUE中标签里调用v-on:click发送axios请求

VUE中标签里调用v-on:click发送axios请求

作者: 随行者pgl | 来源:发表于2020-04-07 16:09 被阅读0次

主要用于实现下载、导出功能。后端传递流,而不是blob对象。

<a>标签的href不为false,且绑定的click向后台发送axios请求实现。
1
这里使用@click不启作用。
调用顺序为先click后跳转链接。
href填写的是后端传递流的url

例子:
html部分:

<a class="el-button--primary" href="www.baidu.com" v-on:click="hello()">
hello
</a>

js部分:

hello(){
                 this.$http({
                    url: '',
                    method: 'post',
                    data: {
                        
                    }
                }).then(res => {
                    console.log(res);
                });
            }

相关文章

网友评论

      本文标题:VUE中标签里调用v-on:click发送axios请求

      本文链接:https://www.haomeiwen.com/subject/gkynphtx.html