-
在tabs里使用upload组件,首先在第一个tab内的upload组件上传一个文件,此时文件列表中是存在这个文件的,但是tabs切换到第二个tab再切换回第一个tab,就会看到第一个tab里的upload组件的文件不见了 https://codesandbox.io/p/sandbox/eager-shadow-yd444j?file=%2Fsrc%2FDemo.vue%3A20%2C1 |
Beta Was this translation helpful? Give feedback.
Answered by
nekorrrr
Mar 5, 2024
Replies: 2 comments
-
问题解决了,需要绑定v-model:file-list来维持选择的文件 <template>
<n-tabs default-value="oasis" justify-content="space-evenly" type="line">
<n-tab-pane name="oasis" tab="Oasis">
<n-upload
action="https://www.mocky.io/v2/5e4bafc63100007100d8b70f"
:headers="{
'naive-info': 'hello!',
}"
:data="{
'naive-data': 'cool! naive!',
}"
v-model:file-list="fileList"
>
<n-button>上传文件</n-button>
</n-upload>
</n-tab-pane>
<n-tab-pane name="the beatles" tab="the Beatles"> Hey Jude </n-tab-pane>
<n-tab-pane name="jay chou" tab="周杰伦"> 七里香 </n-tab-pane>
</n-tabs>
</template>
<script>
import { ref } from "vue";
export default {
setup() {
const fileList = ref([]); // 用于存储文件列表
return {
fileList,
};
},
};
</script>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nekorrrr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题解决了,需要绑定v-model:file-list来维持选择的文件