uniapp如何引入vant ui组件?
网友回复
1、新建一个uniapp项目,选择Vue2,不勾选unilcloud
2、右键项目名,选择菜单在命令行打开

3、输入 npm i vant@latest-v2

4、main.js改成这样
import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import Vant from "vant";
import 'vant/lib/index.less'
Vue.use(Vant)
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif
5、根目录下新增vue.config.js
chainWebpack:(config) => {
config.module
.rule("mjs$")
.test(/\.mjs$/)
.include.add(/node_modules/)
.end()
.type("javascript/auto");
}
6、/page/index.vue
<template> <view class="content"> <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white"> <van-swipe-item>1</van-swipe-item> <van-swipe-item>2</van-swipe-item> <van-swipe-item>3</van-swipe-item> <van-swipe-item>4</van-swipe-item> </van-swipe> <van-grid> <van-grid-item icon="photo-o" text="文字" /> <van-grid-item icon="setting-o" text="文字" /> <van-grid-item icon="home-o" text="文字" /> <van-grid-item icon="video-o" text="文字" /> <van-grid-item icon="photo-o" text="文字" /> <van-grid-item icon="setting-o" text="文字" /> <van-grid-item icon="home-o" text="文字" /> <van-grid-item icon="video-o" text="文字" /> </van-grid> <van-card num="2" price="2.00" desc="描述信息" title="商品标题" thumb="https://repo.bfw.wiki/bfwrepo/image/5ff8f9d574eb5.png" /> <van-card num="2" price="...
点击查看剩余70%


