【发布时间】:2020-03-11 03:43:05
【问题描述】:
文件上传.vue
<template>
<div>
<vue-dropzone
:options="dropzoneOptions">
<div class="dropzone-custom-content" id="custom">
<h3 class="dropzone-custom-title">Drag & Drop</h3>
</div>
</vue-dropzone>
<div>
Content: {{testmsg}}
</div>
</div>
</template>
<script>
import vue2Dropzone from "vue2-dropzone";
import 'vue2-dropzone/dist/vue2Dropzone.min.css'
export default {
components: {
vueDropzone: vue2Dropzone,
},
data() {
return {
dropzoneOptions: {
url: 'http://localhost:5000/',
method: "post",
maxFiles: 1,
thumbnailWidth: 300,
maxFilesize: 500,
success: function (file, responejson) {
this.msg = responejson
console.log(this.msg)
this.testmsg='Hi'
console.log(this.testmsg)
},
console.log(this.testmsg)=>嗨
上传图片后,网络上不会出现值Hi。
附上图片。 控制台窗口结果和场景不会出现在网络上。
这是控制台窗口结果。
内容:没有值出现。
【问题讨论】:
-
你能声明 let $this = this.然后将 this.testmsg 更改为 $this.testmsg
-
让$这个=这个?我应该在哪里申报?
-
让 $this= this 把它放在你的成功函数中,然后在成功函数中把它全部改成 $this,而不是使用这个。顺便说一句,您也可以更改它,它不一定是 $this,您可以随心所欲地更改它。
-
@Renato Manalili 仍然没有回应
-
你是如何渲染 testmsg 的?你有 vue 开发工具吗?它还可以帮助您查看 testmsg 是否收到了数据。
标签: vue.js