我想在屏幕尺寸较小时将微型变量应用于v-navigation-drawer,因此到目前为止,我有以下内容:
<template >
<v-app id="inpire">
<div class="back">
<v-app-bar app>
<v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
<v-spacer></v-spacer>
<h1>{{selectedMethod}}</h1>
</v-app-bar>
<v-navigation-drawer v-model="drawer" src="./assets/bg.png" green app :mini-variant="mini">
<v-list-item
class="y"
v-for="item in items"
:key="item.unidade"
:to="item.link"
@click="change(item.unidade)"
>{{item.unidade}}</v-list-item>
</v-navigation-drawer>
<v-content id="inspire">
<router-view :dcsi="dcsi" :ipe="ipe" :rt="rt" :key="compKey"></router-view>
</v-content>
</div>
</v-app>
</template>
<script>
export default {
name: "App",
data: () => ({
items: [
{ unidade: "IPE", link: "/ipe" },
{ unidade: "DCSI", link: "/dcsi" },
{ unidade: "RT", link: "/rt" }
],
drawer: false,
selectedMethod: "",
unidade: "",
compKey: 0,
methods: {
change(val) {
this.selectedMethod = val;
this.cKey();
},
cKey() {
this.compKey += 1;
console.log(this.compKey);
}
},
watch: {
"$route.params.uni": function() {
this.cKey();
console.log(this.$route.params.uni);
console.log(this.props);
}
},
computed: {
mini() {
switch (this.$vuetify.breakpoint.name) {
case "xs":
return true;
case "sm":
return true;
case "md":
return true;
case "lg":
return false;
case "xl":
return false;
}
}
}
};
</script>
<style lang="stylus" scoped>
#inspire {
background: require('./assets/mg1.jpg') no-repeat center center;
}
.y {
color: green;
}
</style>
作为计算属性,我编写了mini(),根据屏幕尺寸,它会返回true或false。但是我收到以下错误“ 162:9错误,预计将在“迷你”计算属性中返回值”。我不明白为什么,因为它返回一个布尔值。我还尝试将“ mini-variant-md-and-down”作为道具添加到导航抽屉中,该抽屉没有返回任何错误,但也无法正常工作。欢迎在智能手机上使v-navigation-drawer变为迷你的任何提示。
mounted() {
if (
this.$vuetify.breakpoint.name === "md" ||
this.$vuetify.breakpoint.name === "sm" ||
this.$vuetify.breakpoint.name === "xs"
) {
this.mini = true;
}
已解决