vue.js 에서 toast 용법 및 toast 탄 상 자 를 사용 하 는 인 스 턴 스 코드
import { Toast } from 'vant'
소 열 을 쓰다click 이벤트 바 인 딩
2.이벤트 쓰기
methods 에 쓰 는 방법
showToast() {
this.$toast({
message: " +3",
})
},
3.효과 도 는 다음 과 같다.간단 한 toast 힌트 하나 가 성 공 했 습 니 다.
다음은 인 스 턴 스 코드 를 통 해 vue 에서 Toast 탄 상 자 를 사용 하 는 것 을 보 겠 습 니 다.
import { ToastPlugin,ConfirmPlugin,AlertPlugin} from 'vux'
Vue.use(ToastPlugin)
Vue.use(ConfirmPlugin)
Vue.use(AlertPlugin)
// ( )
Vue.prototype.showToast = function( showPositionValue,type,text,width="10em"){
this.$vux.toast.show({
showPositionValue: false,
text: text,
type: type,
width: width,
position: 'middle'
})
}
// alert confirm
const Message = {};
Message.install = () => {
const msg = {
alert: config => {
let def = {
title:' ',
content:' , !',
buttonText:' '
}
if(typeof config === 'string' || typeof config === 'number'){
Vue.$vux.alert.show(Object.assign(def,{content:config}));
}else{
Vue.$vux.alert.show(Object.assign(def,config));
}
},
confirm: config => {
let isConfirm = false;
let def = {
title:' ',
content:' , !',
confirmText:' ',
cancelText:' ',
onConfirm:() =>{
isConfirm = true;
}
}
if(typeof config === 'string' || typeof config === 'number'){
Vue.$vux.confirm.show(Object.assign(def,{content:config}));
}else{
Vue.$vux.confirm.show(Object.assign(def,config));
}
/*return new Promise((resolve,reject) => {
if(isConfirm){
resolve();
}
})*/
},
}
Object.entries(msg).forEach(([method,fn]) => {
Vue.prototype[method] = fn;
})
}
Vue.use(Message)
//
_this.confirm({
title:' ',
content: ' ',
onConfirm() {
console.log(' ');
}
});
총결산위 에서 말 한 것 은 소 편 이 소개 한 vue.js 에서 toast 용법 과 toast 탄 상 자 를 사용 하 는 인 스 턴 스 코드 입 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.소 편 은 제때에 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[백견불여일타/Vue.js] 4장 - 입력 폼 데이터 가져오기v-model 데이터 입력 select 지난 장에서는 v-bind를 이용해서 HTML 태그 속성 값을 Vue로 다루는 법을 배웠습니다. 이번에는 사용자가 입력한 데이터를 Vue로 가져오는 법에 대해 다룹니다. 웹 페...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.