在main.ts里面引入vant
import {
showToast
} from 'vant'
// 创建vue实例
const app = createApp(App)
app.config.globalProperties.$toast = showToast
在某个.vue页面使用轻量提示
import { getCurrentInstance } from 'vue'
const { appContext } = getCurrentInstance()
appContext.config.globalProperties.$toast('提示的内容')
// 需要换行的提示语
appContext.config.globalProperties.$toast({
message: 'This message will contain a incomprehensibilities long word.',
wordBreak: 'break-all',
duration: 3000
})