鍍金池/ 問答/HTML/ 使用element-ui提供的upload組件上傳圖片到本地時,action地址

使用element-ui提供的upload組件上傳圖片到本地時,action地址是后臺處理的地址嗎?

1.element官網(wǎng)提供的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參數(shù)為上傳的地址,我想要上傳到項目所在目錄的images文件夾下,地址寫成了
"http://localhost:63342/springcloudservice/page-server/templates/images/",但是前端控制臺報錯404,不能直接這么寫地址嗎?

回答
編輯回答
空白格

這里不是直接寫個目錄,是要寫個api地址,接收你上傳的數(shù)據(jù),然后存到這個目錄

2017年11月6日 01:17