总结:vue 弹窗的几总方式

前提:已经引入Modal

点击测试按钮出现弹框;

<Button type="primary"  @click="test">测试</Button>

一:简单使用Modal;

   在<template>中写html中:

把弹窗的内容写上:

  <!--test窗口-->
	<Modal v-model="isDisplay" :title="弹窗测试!" label-position="right" :scrollable="true" width="340px">
	
				<Input :placeholder="请输入!" size="large" v-model="testS"></Input>

		<div slot="footer">
			<Button type="primary"  @click="cancel2">取消</Button>
			<Button type="primary"  @click="modalSubmit">发送</Button>
		</div>
	</Modal>

在<script>中,

<script>
   data () {
       isDisplay:false
},
 test(){
this.isDisplay=true;
}

</script>

二:在<script>中,

	  test: function () {
			  var that = this;
			  this.$Modal.confirm({
				  title: 测试!,
				  cancelText:取消,
				  okText:发送,
				  onOk: function () {
					 在这可以写校验数据的逻辑
                       
                      //点击发送按钮触发的请求
					  that.$http.post("URL",{
							传入后台的参数
					  }).then(res => {
					  	获取后台返回来的结果处理
					  });
				  },
				  render: (h) => {
                         
					  return h('Input', {
                          //Input为导入的输入组件
						  props: {
							  value: that.testInput,
							  icon: "",
							  width: "440px",
							  height:"28px",
							  autofocus: true,
							  placeholder: "请输入!")
						  },  on: {//监听输入框中输入的数据
							  input: (val) => {
								  that.testInput = val;
							  }
						  },

			  			});
		  			}});
			  },

三:提示弹框

使用$Message:

this.$Message.info("提示语");
使用$Modal
this.$Modal.warning({
   title: 测试,
   content: 测试内容,
   okText: 确认,
   closable: true
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值