使用element-ui提供的upload组件上传图片到本地时,action地址是后台处理的地址吗?

1.element官网提供的demo,上传图片


<body>

<div id="app">

<el-upload class="upload-demo" action="http://localhost:63342/springcloudservice/page-server/templates/images/project/"

        :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove"

        multiple :limit="3" :on-exceed="handleExceed" :file-list="fileList">

    <el-button size="small" type="primary">点击上传</el-button>

    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>

</el-upload>

</div>

</body>

<script>

var vue=new Vue({

    el: '#app',

    data() {

        return {

            fileList: [

                {

                    name: 'food.jpeg',

                    url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'

                },

                {

                    name: 'food2.jpeg',

                    url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'

                }

            ]

        };

    },

    methods: {//这里用于定义方法

        handleRemove:function(file, fileList) {

            console.log(file, fileList);

        },

        handlePreview:function(file) {

            console.log(file);

        },

        handleExceed:function(files, fileList) {//当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件

            this.$message.warning('限制为3个');

        },

        beforeRemove:function(file, fileList) {

            return this.$confirm('确定移除 '+ file.name +'?');

        }

    },

    computed: {//计算属性

    }

})

</script>

2.action参数为上传的地址,我想要上传到项目所在目录的images文件夹下,地址写成了

"http://localhost:63342/springcloudservice/page-server/templates/images/",但是前端控制台报错404,不能直接这么写地址吗?


蝴蝶不菲
浏览 9659回答 1
1回答

aluckdog

这里不是直接写个目录,是要写个api地址,接收你上传的数据,然后存到这个目录
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript