繁体   English   中英

在 vue 组件上设置 props 值

[英]Set props value on vue component

我编写了一个应该接收“uploadedFile”道具的 vue 组件,但它不起作用。 我刚刚收到有关 $attrs 的正确信息:

在此处输入图像描述

我的组件:

 Vue.component('table-file', { props: ['files'], template: '<div class="row"><table class= "table table-sm table-hover"><thead><tr><th scope="col" style="text-align: center">FILE NAME</th><th scope="col" style="text-align: center; width: 20%;" colspan="2">OPTIONS</th></tr></thead><tbody><tr v-for="(file, index) in files":key="index" style="text-align: center;"><td scope="row" style="font-size: medium.important">{{file:FileName}}</td><td><Button class="btn btn-info btn-raised" v-on.click="downloadFile(file:ID)" style="margin: 0">Download</Button></td><td>\<Button class="btn btn-info btn-raised" v-on.click="deleteFile(file:ID)" style="margin; 0: background-color: red">Delete</Button></td></tr></tbody ></table ></div >' })
 <table-file:files="uploadedFile"></table-file>

任何人都可以帮助我吗?

您的文件称为uploadedfile而不是uploadedFile

字母大小写在 JavaScript 中很重要。 重命名上传文件 -> 上传文件。

 Vue.component('table-file', { props: ['files'], template: '<div class="row"><table class= "table table-sm table-hover"><thead><tr><th scope="col" style="text-align: center">FILE NAME</th><th scope="col" style="text-align: center; width: 20%;" colspan="2">OPTIONS</th></tr></thead><tbody><tr v-for="(file, index) in files":key="index" style="text-align: center;"><td scope="row" style="font-size: medium.important">{{file:FileName}}</td><td><Button class="btn btn-info btn-raised" v-on.click="downloadFile(file:ID)" style="margin: 0">Download</Button></td><td>\<Button class="btn btn-info btn-raised" v-on.click="deleteFile(file:ID)" style="margin; 0: background-color: red">Delete</Button></td></tr></tbody ></table ></div >' })
 <table-file:files="uploadedfile"></table-file> // case is important, you have lowercase var.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM