0
点赞
收藏
分享

微信扫一扫

文件上传预览,前端代码。后端代码在上次的demo中

程序猿不脱发2 2022-01-03 阅读 50

书接上回,测试demo用到的前端vue后端springboot做得文件上传预览功能,此处为前端代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
    <div id="app">
        <el-upload
                action="/upload"
                :on-preview="handlePreview"
                accept=".pdf"
                :limit="10">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
        </el-upload>
    </div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
new Vue({
    el: '#app',
    methods:{
        handlePreview(file){
            debugger
           window.open(file.response.url);
        }
    }
})
</script>
</body>
</html>
举报

相关推荐

0 条评论