出现问题原因:
组件库引入Toast时,变量名互相冲突,导致页面发版后出现错误。
如何解决:
解决变量冲突问题即可
1.首先在main.js引入vant
import {Loading, Overlay, NavBar, Toast, Col, Row, Icon, Button} from 'vant'
Vue.use(Loading);
Vue.use(Overlay);
Vue.use(NavBar);
Vue.use(Toast);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Icon);
2.新建js文件,代码如下
//引入vue-ydui
import { Confirm, Alert, Toast, Notify, Loading } from 'vue-ydui/dist/lib.rem/dialog'
var Confirms=Confirm
var Alerts=Alert
var Toasts=Toast
var Notifys=Notify
var Loadings=Loading
export{Confirms,Alerts,Toasts,Notifys,Loadings}
3.在main.js引入js文件,结构赋值
//引入vue-ydui
import {Confirms,Alerts,Toasts,Notifys,Loadings} from './mainConflict'
Vue.prototype.$dialogs = {
confirm: Confirms,
alert: Alerts,
toast: Toasts,
notify: Notifys,
loading: Loadings
};
4.页面中使用
//使用vue-ydui
this.$dialogs.toast({mes: "签到成功!", timeout: 1000});
//使用vant
this.$toast(('未整改禁止确认'));