Giter Site home page Giter Site logo

vant-nuxt's Introduction

logo

Vant Nuxt

Vant module for Nuxt

Features

  • Automatically import components and styles on demand.
  • Automatically import of showDialog, showToast and other methods.

Install

npx nuxi@latest module add vant
# or
npm i vant @vant/nuxt -D
export default defineNuxtConfig({
  modules: ['@vant/nuxt'],
  vant: {
    /** Options */
  },
});

Usage

<template>
  <van-button type="primary" @click="showToast('toast')">button</van-button>
  <VanButton type="success" @click="showNotify('notify')">button</VanButton>
  <LazyVanButton type="default">lazy button</LazyVanButton>
</template>

Reference Nuxt documentation and playground use.

Options

lazyload

  • Type: boolean | object
  • Default: false

How to load directives and components from lazyload.

eg. { lazyComponent: true }

importStyle

  • Type: boolean
  • Default: true

Whether to automatically import styles.

excludeExports

  • Type: array
  • Default: ['Lazyload', 'Locale']

Exclude exports from Vant that are not component content.

components

  • Type: array

If there are components that are not imported automatically from Vant, you need to add the component here.

imports

  • Type: array

If you wish to add automatically import content from Vant, you can add it here.

include

  • Type: array
  • Default: [ /\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.((c|m)?j|t)sx?$/]

Include files that need to automatically import styles.

exclude

  • Type: array
  • Default: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]

Exclude files that do not require the automatic import of styles.

Development

  • Run pnpm i to install the dependencies.
  • Run pnpm dev:prepare to generate type stubs.
  • Run pnpm dev to start playground in development mode.
  • Run pnpm dev:build to build playground.
  • Run pnpm dev:start to locally preview playground.
  • Run pnpm build to build this project.

vant-nuxt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vant-nuxt's Issues

van-image-preview

van-image-preview v-model:show="show" :startPosition="index" transition="van-fade" :images="images"
template #image="{ src }"
img :src="src"/
template
van-image-preview

使用了vant-nuxt用这段代码只显示第一张图,鼠标左右拉都不动。我是在电脑上测试,但用plugin的方式自己写一个手工插件的方式就可以。注明已安装@vant/touch-emulator,而且我在调式的时候发现你们这个方式加载多少个组件就加载多少个css出来,这实在是太占连接了。应该弄成一个总的出来。否则人流量大的时候,服务器连接资源都被占光了。

cascader组件需要包裹ClientOnly才能正常使用

<van-popup v-model:show="showCascader" round position="bottom">
  <van-cascader
    v-model="cascaderValue"
    title="请选择所在地区"
    :options="options"
    @close="showCascader = false"
  />
</van-popup>

这样直接使用会卡顿,我加上<ClientOnly>后正常

<van-popup v-model:show="showCascader" round position="bottom">
  <ClientOnly>
    <van-cascader
      v-model="cascaderValue"
      title="请选择所在地区"
      :options="options"
      @close="showCascader = false"
    />
  </ClientOnly>
</van-popup>

Cannot find package 'vant'

I'm getting an error when I try to use this module using yarn add -D @vant/nuxt alone as stated on the README:

Cannot find package 'vant' imported from .../node_modules/@vant/nuxt/dist/module.mjs

I still need to install vant manually with yarn add -D vant.

自动引入组件css分离后因加载顺序异常导致显示错误

包版本:
nuxt:3.8.2
Nitro:2.8.1
Vant:4.8.0
@vant/nuxt:1.0.4
问题:
css文件顺序导致多个类名的元素css属性被覆盖
复现:
问题暂时无法提供最小化情况复现,在nuxt dev时不存在该情况
复现要求:
1.项目总体积达到一点程度后
会因为多两行行注释而异常,少两行注释则正常,也是无法提供最小化复现的原因
猜测当总体积小于一定量的时候,vant的样式不会被拆分,会全部放在entry.css中
2.需要通过nuxt build出来node运行
3.受路由影响
首页跳转到页面a,点击触发showImagePreview => 异常
直接通过完整访问ssr的路由,点击触发showImagePreview => 正常
4.影响组件包括但不限于showImagePreview、van-search
上诉4点须同时满足,暂未确定其他影响因素

表现:
异常表现:
QQ截图20231208143054
期望/正常表现:
QQ截图20231208143223

暂时的解决方案:
弃用@vant/nuxt,使用传统模式注册vant,如
/plugins/vant.js
`import vant from 'vant'
import 'vant/lib/index.css'

export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(vant)
})
`

Error:can't import Layload on startup

once the @vant/nuxt installed and run the Dev, the error occur:

ERROR Failed to resolve import "vant/es/lazyload/Lazyload" from "virtual:nuxt:D:\projects\www.ok.ltd.nuxt\components.client.mjs".

could you help me?

使用 `@vant/nuxt` 问题

使用 @vant/nuxt 之后是否还需要在 nuxt.config.ts 中配置 transpile

build: {
  transpile: ['vant'],
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.