首页 > 其他分享 >trao项目怎么跨端安装vant组件库

trao项目怎么跨端安装vant组件库

时间:2024-02-21 22:33:42浏览次数:28  
标签:const vant text trao value 跨端 false ref

一、安装依赖

npm install vant

二、添加 web 标签适配插件

在 config / index.js 文件

const config = {
  // ...
  plugins: [
    [
      "@tarojs/plugin-html",
      {
        // 过滤 vant 组件库的前缀:van-
        pxtransformBlackList: [/van-/],
      },
    ],
  ],
};

三、在页面中直接使用

<template>
    <view class="buyTicket-goschool">
        <view class="picker">
            <nut-cell title="请选择城市" :desc="String(val)" @click="show = true"></nut-cell>
            <nut-popup v-model:visible="show" position="bottom">
                <nut-picker v-model="val" :columns="columns" title="请选择城市" @confirm="confirm" @cancel="show = false" />
            </nut-popup>
            内容
            <van-button type="default" @click="show2==true">默认按钮</van-button>
            <van-popup v-model="show2" position="top" :overlay="false">
                内容
            </van-popup>

        </view>

    </view>
</template>
<script setup>
import { ref } from 'vue';
import {Button, Popup} from 'vant'

// 选择器
const show = ref(false);
const show2 = ref(false);
const val = ref();
const columns = ref([
    { text: '南京', value: 'Nanjing' },
    { text: '无锡', value: 'Wuxi' },
    { text: '海北', value: 'Haibei' },
    { text: '北京', value: 'Beijing' },
    { text: '连云港', value: 'Lianyungang' },
    { text: '长沙', value: 'Changsha' },
    { text: '武汉', value: 'Wuhan' }
]);

const confirm = ({ selectedValue, selectedOptions }) => {
    console.log(selectedValue[0], selectedOptions[0]);
    show.value = false;
};


</script>


<style lang="scss">
.buyTicket-goschool {
    margin-top: 20px;
    border: 1px solid #000;

    .picker {
        border: 1px solid red;
    }
}
</style>

 

标签:const,vant,text,trao,value,跨端,false,ref
From: https://www.cnblogs.com/fairya/p/18026351

相关文章

  • Vue3+Vant+Vite H5移动端开发(二)
    vue3项目创建使用vue创建项目命令npmcreatevue@latest基础配置配置IP和localhost打开项目,修改'package.json'文件下的‘scripts’配置--host0.0.0.0显示ip地址可以打开项目--open启动项目,在浏览器中自动打开"scripts":{"dev":"vite--host0.0.0.0......
  • vue3+ts使用插件vue3-esign完成签字、重签(h5、vant)
    1.安装vue3-esign:npmivue3-esign2.main.ts中引入:importVue3Esignfrom'vue3-esign'app.use(Vue3Esign)3.页面中代码:<van-nav-bartitle="手写签字"left-arrowfixed/><divid="sign_box"><divclass="text&......
  • "@vant/weapp/dist/col/index" 未找到----路径错误
    错误提示如图: 官方文档是这样引入的: 但是我看了一下npm库的目录:可以发现引入目录名字都不一样我们手动改即可 再运行就不报错了 ......
  • 微信小程序中使用Vant Weapp组件库
    【快速上手-VantWeapp(gitee.io)】【node版本对应的npm版本表-菜小鱼~-博客园(cnblogs.com)】【报错npmERR!Acompletelogofthisruncanbefoundin:npmERR!-CSDN博客】【解决:npminstall报错‘Theoperationwasrejectedbyyouroperatingsystem‘-C......
  • Vantage客服我们很安全,牌照自己公司授权使用?
    今日是iFXEXPO,迪拜世博展的最后一天~不过今天真相哥要带大伙看的是,昨天参展的券商Vantage~从这次展会的赞助商展牌来看,Vantage在此次展会中的规模应该是中等偏下的,Vantage和STARTRADERPRIME以及UltimaMarkets独占一栏,而Exness可谓是这次展会的老大,,独占“C”位~话题扯远了,让我们......
  • vue3使用 vant ui 3 如何获取组件 popup dom的高度?
    我目前使用的是vant-ui 3.1.2popup弹出层组件,我想要获取弹出层的高度来计算一些东西,但是使用常规定义refdom的方式总是无法获取,最终找到方案如下:vant-ui官方文档:https://vant-contrib.gitee.io/vant/v3/#/zh-CN/popup<template><van-popupv-model:show="show......
  • 【五期李伟平】CCF-A(AAAI'21)Game of Gradients: Mitigating Irrelevant Clients in Fe
    Nagalapatti,Lokesh,andR.Narayanam."GameofGradients:MitigatingIrrelevantClientsinFederatedLearning."(2021).  针对联邦学习中相关客户端选择(FRCS)的问题,本文提出一种可以选择具有相关数据的客户端的方法,并提出一个检测拥有特定目标标签数据的客户端......
  • 遇到跨端开发或多项目开发时,遇到的一些问题探讨,后端开发语言如何选择?
    ​ 最近有同学问我,做后端开发项目时用php,java,c#,go,pathon...哪个好,从最近阿里云、美团服务器崩溃来看,我想给你最直接的回答是,没有完美的,只有适合自己的。咱们讨论最多的问题就是跨多端开发,以及多项目开发后期所带来的升级、维护等相关问题,接下来就该问题,我发表一点自己的看法,也算是......
  • What do you think of Online and Classroom Class advantages and disadvantages?
    WhatdoyouthinkofOnlineandClassroomClassadvantagesanddisadvantages? Onlineandclassroomclasseseachhavetheirownsetofadvantagesanddisadvantages,whichcanmakethemmoreorlesssuitablefordifferentstudentsandlearningsituations.Ad......
  • 在Python中实现ESG(环境、社会、治理)因子的交易策略,我们可以使用pandas库来读取数据,并
    在Python中实现ESG(环境、社会、治理)因子的交易策略,我们可以使用pandas库来读取数据,并使用AlphaVantage提供的API来获取股票价格数据²。以下是一个简单的代码示例:importpandasaspdimportrequests#获取股票价格数据response=requests.get(alpha_vantage_url)data=res......