本文主要是介绍Vue中引用mint-ui时,Toast和Indicator的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在mint-ui的官方文档中,介绍使用Toast和Indicator时,以Indicator为例,文档示例是通过Indicator.open();等方式来使用。可是如果我们这样使用,会发现会报Indicator is not defined的错误,根本用不了。
后来在通过查找的过程中,看到有人说Toast和Indicator是例外,首字母要用小写,正确的用法是:
全部引用
// 引用时
import Mint from 'mint-ui';
Vue.use(Mint);// 使用时
this.$indicator.open('加载中...');
按需引用
另外,如果你是使用按需引用的方式,则应该是
// 引入时
import { Indicator } from 'mint-ui'
Vue.prototype.$Indicator = Indicator// 使用时
this.$Indicator.open('加载中...');
参考链接:
https://segmentfault.com/q/1010000015766216
https://blog.csdn.net/weixin_38787614/article/details/86595925
这篇关于Vue中引用mint-ui时,Toast和Indicator的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!