NothingToU 2023-04-17 22:48 采纳率: 83.3%
浏览 14

vite生成vue项目使用vant组件样式问题

vite生成的vue项目中,用了vant组件库的组件,有些组件不能铺满整个空余屏幕只能固定大小,我猜测可能是因为新版本css或者组件的一些默认值改变了导致的,不知道该怎么修改呢?

img

img

这是搜索页面的代码

<template >
  <form action="/" >
    <van-search
        v-model="searchText"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
    />
  </form>
  <van-divider>已选标签</van-divider>
  <div v-if="activeIds.length === 0">请选择标签</div>
  <van-row gutter="16" style="padding: 0 16px">
    <van-col v-for="tag in activeIds">
      <van-tag closeable size="medium" type="primary" @close="close(tag)">
        {{ tag }}
      </van-tag>
    </van-col>
  </van-row>

  <van-divider>全部标签</van-divider>
  <van-tree-select
      v-model:active-id="activeIds"
      v-model:main-active-index="activeIndex"
      :items="tagList"
  />
</template>
<script setup>
import {ref} from 'vue';

const searchText = ref('');
const originTagList = [
  {
    text: '性别',
    children: [
      {text: '男', id: '男'},
      {text: '女', id: '女'},
    ],
  },
  {
    text: '年级',
    children: [
      {text: '大一', id: '大一'},
      {text: '大二', id: '大二'},
      {text: '大3', id: '大3'},
      {text: '大4', id: '大4'},
      {text: '大5', id: '大5aaaaaa'},
      {text: '大6', id: '大6aaaaaa'},
    ],
  },
];
let tagList = ref(originTagList)
const onSearch = (val) => {
  tagList.value = originTagList.map(parentTag => {
    const tempChildrenTag = [...parentTag.children];
    const tempParentTag = {...parentTag};
    tempParentTag.children = tempChildrenTag.filter(item => item.text.includes(searchText.value)
    )
    return tempParentTag;
  })
};
const onCancel = () => {
  searchText.value = '';
  tagList.value = originTagList
};


const activeIds = ref([]);
const activeIndex = ref(0);
const close = (tag) => {
  activeIds.value = activeIds.value.filter(id => id !== tag)
}

</script>

<style scoped>

</style>


这是信息页面的代码

<template>
  <van-cell title="头像" is-link>
    <img :src="user.avatar" alt="" style="height: 46px">
  </van-cell>
  <van-cell title="昵称" is-link :value="user.userName" @click="toEdit('userName', user.userName, '昵称')"/>
  <van-cell title="账号" :value="user.userAccount"/>
  <van-cell title="性别" is-link :value="user.gender" @click="toEdit('gender', user.gender, '性别')"/>
  <van-cell title="电话" is-link :value="user.phone" @click="toEdit('phone', user.phone, '电话')"/>
  <van-cell title="邮箱" is-link :value="user.email" @click="toEdit('email', user.email, '邮箱')"/>
  <van-cell title="星球编号" :value="user.planetCode"/>
  <van-cell title="注册时间" :value="user.gmtCreate"/>
</template>

<script setup lang="ts">

import {ref} from "vue";
import {useRouter} from "vue-router";

const user = ref({
  id: 1,
  userName: 'ccc',
  userAccount: 'ccc',
  gender: '男',
  phone: '11',
  email: '118@qq.com',
  planetCode: '123',
  avatar: 'https://img2.baidu.com/it/u=1790834130,1952230725&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
  gmtCreate: new Date().toDateString()
})

const router = useRouter();
const toEdit = (editKey: string, currentValue: string, editName: string) => {
  router.push({
    path: '/user/edit',
    query: {
      editKey,
      currentValue,
      editName
    }
  })
}

</script>

<style scoped>

</style>

  • 写回答

3条回答 默认 最新

  • 白云苍狗い 2023-04-18 08:15
    关注

    是不是有项目的初始css没处理,你试试原生的标签写个页面看看能铺满全屏吗

    评论

报告相同问题?

问题事件

  • 创建了问题 4月17日

悬赏问题

  • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
  • ¥15 算能的sail库的运用
  • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码
  • ¥15 AutoDL无法使用docker install吗?
  • ¥15 cups交叉编译后移植到tina sdk的t113,只需要实现usb驱动打印机,打印pdf文件
  • ¥30 关于#wireshark#的问题:需要网络应用流量数据集需要做长度序列的实验,需要与应用产生的会话的数据包的长度,如视频类或者聊天类软件
  • ¥15 根据上述描述表示泥浆密度沿着管路的长度方向在不断变化,如何来表示泥浆密度随管路的变化(标签-matlab|关键词-流计算)