vant toast轻提示 看了之后立马就会的那种 零基础上手 vue2调用vant toast轻提示

vue2调用vant toast轻提示

首先在main.js导入我们的vant组件

import Vant from 'vant';
import 'vant/lib/index.css';
import {
    
     Toast } from 'vant';
Vue.use(Toast);
Vue.use(Vant);

在标签上绑定一个点击事件

<van-goods-action-icon @click="getCollect" />

在我们想使用的组件中编写 使用的时候要写this.$toast

methods: {
    
    
	getCollect() {
    
    
		this.$toast({
    
    
      	message: "收藏成功 ",   
        icon: 'star-o',  // 这个icon是自定义的  自己可以去vant查看icon图标 然后把这个替换掉
    })
  }
}

猜你喜欢

转载自blog.csdn.net/qq_53135313/article/details/129296363