【发布时间】:2021-05-30 08:53:09
【问题描述】:
我对 vue-leaflet 和 vuetyfy 有疑问。我有一个简单的模板,它显示不同的布局取决于移动设备与否。如果应用程序检测到移动设备,我想制作 2 行布局,第一个地图,第二个用于输入表单。但是该地图占据了该地图上方显示的所有屏幕空间和输入表单。我的桌面屏幕的第二个布局工作正常,我只是将 w-50 类设置为 map 等等。我试图将 h-50 设置为地图,但它没有按预期工作。如何解决这个问题?
我的布局是这样的:
<template>
<v-container fluid v-if="mobile">
<v-row class="mb-5">
<v-col class="pl-0">
<Map marker="true" />
</v-col>
</v-row>
<v-row>
<v-col>
<AddPlaceDescription />
</v-col>
</v-row>
<Footer />
</v-container>
<v-container fluid v-else>
<v-row>
<v-col class="px-0">
<Map class_attr="w-50" marker="true" />
</v-col>
<v-col>
<AddPlaceDescription />
</v-col>
</v-row>
<Footer />
</v-container>
</template>
这是我的地图组件
<template>
<l-map
id="themap"
:class="class_attr"
:zoom="zoom"
:center="center"
@update:zoom="zoomUpdated"
@update:center="centerUpdated"
@update:bounds="boundsUpdated"
>
<l-tile-layer :url="url" ></l-tile-layer>
<v-marker-cluster>
<l-marker
v-if="marker"
ref="marker"
draggable
@dragend="onDragEnd"
:latLng="center"
></l-marker>
<l-marker
v-for="marker in markersData"
:key="marker['latLng'][0]"
:lat-lng="marker['latLng']"
>
<l-popup><a href="#">{{marker['description']}}</a></l-popup>
</l-marker>
</v-marker-cluster>
</l-map>
</template>
AddPlaceDescription 组件
<template>
<v-row>
<v-col class="ml-3">
<v-alert
v-if="showMsg"
border="left"
:color="msgColor"
outlined
text
type="error"
>{{ msg }} {{countDown}} </v-alert
>
<form action="">
{{ this.$store.state.Map.markerLatLng }}
<v-textarea
outlined
name="place-description"
label="Description"
v-model="description"
:disabled='showMsg'
></v-textarea>
<v-btn @click="sendPoint" :disabled='showMsg'>Send</v-btn>
<v-btn @click="clearForm" :disabled='showMsg'>Clear</v-btn>
</form>
</v-col>
</v-row>
</template>
这样的结果
【问题讨论】:
-
会不会是你的 Map 组件是绝对定位的?它可以解释为什么表格出现在地图的顶部。应用于它的 CSS 是什么?与您在移动设备上的布局问题无关:为避免重复代码,我建议使用一个 v-container 而不是两个,并改用网格系统:vuetifyjs.com/en/components/grids
-
@valentin,我更新了我的问题,在那里添加组件代码。现在您可以看到,我没有使用任何自定义 css 样式。当我通过浏览器开发人员工具看到我的地图组件时,它的位置是固定的。我曾尝试在开发人员工具中使用位置,但没有成功。有什么建议吗?
标签: vue.js vuejs2 leaflet vuetify.js