File tree 3 files changed +22
-3
lines changed
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
+ import enUS from ' vant/es/locale/lang/en-US'
3
+ import zhCN from ' vant/es/locale/lang/zh-CN'
4
+
5
+ const lang = useCurrentLang ()
6
+
2
7
const showCalendar = ref (false )
3
8
const showPopup = ref (false )
4
9
const showCascader = ref (false )
@@ -41,6 +46,13 @@ const onConfirm = (value: Date) => {
41
46
const showImage = (index : number ) => {
42
47
showImagePreview ({ images: imageList , startPosition: index })
43
48
}
49
+ const changeLocale = () => {
50
+ if (lang .value === ' en-US' ) {
51
+ Locale .use (' zh-CN' , zhCN )
52
+ } else {
53
+ Locale .use (' en-US' , enUS )
54
+ }
55
+ }
44
56
45
57
onMounted (() => {
46
58
showNotify (' 通知内容' )
@@ -87,6 +99,9 @@ onMounted(() => {
87
99
<LazyVanButton type =" success" @click =" openFloatingPanel" >
88
100
Open Floating Panel
89
101
</LazyVanButton >
102
+ <van-button type =" warning" @click =" changeLocale" >
103
+ i18n
104
+ </van-button >
90
105
</van-col >
91
106
<van-col span =" 4" >
92
107
<van-icon name =" chat-o" />
@@ -120,6 +135,7 @@ onMounted(() => {
120
135
弹出默认键盘
121
136
</van-cell >
122
137
</van-cell-group >
138
+ <van-pagination :total-items =" 24" :items-per-page =" 5" />
123
139
124
140
<van-collapse v-model =" activeNames" >
125
141
<van-collapse-item title =" 标题1" name =" 1" >
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import Vant from '..'
4
4
export default defineNuxtConfig ( {
5
5
modules : [ Vant ] ,
6
6
vant : {
7
- lazyload : true
7
+ lazyload : true ,
8
+ imports : [ 'Locale' , 'useCurrentLang' ]
8
9
}
9
10
} )
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ import { libraryName } from '../config'
3
3
4
4
export function resolveOptions ( ) {
5
5
const nuxt = useNuxt ( )
6
- const regExp = new RegExp ( `${ libraryName } /es/.*/style/index.mjs` )
7
6
8
- nuxt . options . build . transpile . push ( regExp )
7
+ nuxt . options . build . transpile . push ( libraryName )
8
+ nuxt . options . vite . optimizeDeps ??= { }
9
+ nuxt . options . vite . optimizeDeps . exclude ??= [ ]
10
+ nuxt . options . vite . optimizeDeps . exclude . push ( libraryName )
9
11
}
You can’t perform that action at this time.
0 commit comments