我正在尝试使用Buefy组件创建文件放置区域,但希望放置区域的大小为宽度和高度的100%。这是基本页面,但我不知道需要在哪里放置宽度和高度样式。
如果我加载了Chrome浏览器并手动更新了内联添加样式,最终将获得所需的效果(请参见屏幕截图)。我应在哪里将样式添加到实际的Buefy组件中?
下面是代码,代码笔是here。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.5.94/css/materialdesignicons.min.css">
</head>
<body>
<div id="app">
<!-- Buefy components goes here -->
<section>
<b-field>
<b-upload v-model="dropFiles"
multiple
drag-drop
>
<section class="section">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large">
</b-icon>
</p>
<p>Drop your files here or click to upload</p>
</div>
</section>
</b-upload>
</b-field>
<div class="tags">
<span v-for="(file, index) in dropFiles"
:key="index"
class="tag is-primary" >
{{file.name}}
<button class="delete is-small"
type="button"
@click="deleteDropFile(index)">
</button>
</span>
</div>
</section>
</div>
<script src="https://unpkg.com/vue"></script>
<!-- Full bundle -->
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
<!-- Individual components -->
<script src="https://unpkg.com/buefy/dist/components/table"></script>
<script src="https://unpkg.com/buefy/dist/components/input"></script>
<script>
new Vue({
el: '#app',
data: {
dropFiles: []
},
methods: {
deleteDropFile(index) {
this.dropFiles.splice(index, 1)
}
}
})
</script>
</body>
</html>
答案 0 :(得分:0)
这是css问题,或者是buefy问题。 您必须将css添加到页面中,可以将其添加到页面的头部,但是您应该使用外部css文件并将其导入页面中。
因此,要解决您的问题,只需将其添加到您的脑袋:
.upload {
width: 100%;
}
.upload-draggable {
width:100%;
height: 100vh;
}
使用您的代码完成示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.5.94/css/materialdesignicons.min.css">
<style>
.upload {
width: 100%;
}
.upload-draggable {
width:100%;
height: 100vh;
}
</style>
</head>
<body>
<div id="app">
<!-- Buefy components goes here -->
<section>
<b-field>
<b-upload v-model="dropFiles"
multiple
drag-drop
>
<section class="section" style="width:100%">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large">
</b-icon>
</p>
<p>Drop your files here or click to upload</p>
</div>
</section>
</b-upload>
</b-field>
<div class="tags">
<span v-for="(file, index) in dropFiles"
:key="index"
class="tag is-primary" >
{{file.name}}
<button class="delete is-small"
type="button"
@click="deleteDropFile(index)">
</button>
</span>
</div>
</section>
</div>
<script src="https://unpkg.com/vue"></script>
<!-- Full bundle -->
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
<!-- Individual components -->
<script src="https://unpkg.com/buefy/dist/components/table"></script>
<script src="https://unpkg.com/buefy/dist/components/input"></script>
<script>
new Vue({
el: '#app',
data: {
dropFiles: []
},
methods: {
deleteDropFile(index) {
this.dropFiles.splice(index, 1)
}
}
})
</script>
</body>
</html>