使用vant时Toast组件时提示not defined的问题

我在main的js中将vant组件全部加载的

import 'view-design/dist/styles/iview.css';
import Vant from 'vant';

import 'vant/lib/index.css';

Vue.use(Vant);

然后在组件中调用时
Toast.时报

Error in created hook: "ReferenceError: Toast is not defined"

this.$toast出来的提示框长得我是看不出来区别,仔细研究一下,在组件内 import { Toast } from 'vant'就行了,完整示例如下

对对对

<template>
  <div>

  </div>
</template>
<script>
  import {
    Toast
  } from 'vant'

  export default {
    data() {
      return {}
    },
    created() {
      // this.$toast({
      //   type:'loading',
      //   message: '更新aa成功',
      // });
      Toast.fail('失败文案');
    },
  };
</script>

<style>
</style>

单独

原文地址:https://www.cnblogs.com/yanan7890/p/14454151.html