使用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>

 

 

單獨


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM