vue页面带参跳转(用requirejs进行模块化)
来源:互联网 发布:唯一网络招聘 编辑:程序博客网 时间:2024/05/16 16:09
最近开始用vue,对其简单地运用记录一下。
首先项目结构如下所示:
要实现的是从发送短信模块带参数跳到下个页面
首先:
在有跳转得页面的跳转按钮用标签包住:
<router-link></router-link>
加上
:to=”{path:’xzjsr’,query: {id:postdata.dept_id}}”
代码如下:
<router-link class="xzjsr" :to="{path:'xzjsr',query: {id:postdata.dept_id}}"> <input type="text" name="" id="" value="" readonly="readonly"/> <img src="./img/contact.png"/></router-link>
在需要接受参数的页面中解析参数:
this.$route.query.id
上面就是获取url参数中的方法。
完整例子如下:
dxfs.html:
<div> <header class="headerfield"> <div class="button left0" v-on:click="goback"> <span></span>返回 </div> <div class="title" >短信发送</div> <div class="button right0"></div> </header> <div class='dxfsield'> <ul class="input-field"> <li> <label for=""> <span>选择部门{{postdata.dept_id}}</span> <select name="" v-model="postdata.dept_id" @change="getchange()"> <option value="" v-for="dep in departmentMsg" v-bind:value="dep.dept_id">{{dep.dept_name}}</option> </select> </label> </li> <li> <label for=""> <span>接收人{{postxzjsr}}</span> <!--<input type="text" name="" id="" value="" />--> <router-link class="xzjsr" :to="{path:'xzjsr',query: {id:postdata.dept_id}}"> <input type="text" name="" id="" value="" readonly="readonly"/> <img src="./img/contact.png"/> </router-link> <!--<select name="" v-model="postdata.recid"> <option value="" v-for="send in SendeeMsg" v-bind:value="send.user_id">{{send.user_name}}</option> </select> <img src="./img/contact.png"/>--> </label> </li> <li> <label for=""> <span>内容</span> <textarea name="" rows="" cols="" v-model="postdata.content"></textarea> </label> </li> </ul> <div class="button-field"> <button class="button button-block" @click="sendMsg()"> 发送短信 </button> </div> </div></div>
dxfs.js:
define(['vue', 'txt!../pages/dxfs.html','base'], function(v, dxfshtml) { var Foo = v.extend({ template: dxfshtml, data:function(){ base = { goback:function(){ window.history.back(); }, departmentMsg:[], //部门数据 SendeeMsg:[], //接收人 postdata:{}, //传输数据 postxzjsr:'' }; return base; }, mounted: function() { //选择部门模拟数据 base.departmentMsg=[ { "dept_id":01, "dept_name":"01" }, { "dept_id":02, "dept_name":"02" }, { "dept_id":03, "dept_name":"03" }, { "dept_id":04, "dept_name":"04" }, { "dept_id":05, "dept_name":"05" }, { "dept_id":06, "dept_name":"06" }, { "dept_id":07, "dept_name":"07" }, { "dept_id":08, "dept_name":"08" } ] }, methods:{ //选择部门 getchange:function(){//console.log(base.postdata.id) base.postxzjsr=base.postdata.id;//console.log(base.postdata.id)// console.log(base.postxzjsr) },// //接收人在一个页面的下拉框// getSendee:function(){// base.postdata.inf_account='thapp';// base.postdata.inf_token='123qwe!@#';// //base.postdata.id='TEST';// //base.postdata.id=id;// base.postdata.id=base.postdata.dept_id;// console.log(base.postdata.id)// if(base.postdata.id==undefined){// baseobj.layerobj.alertmsg("请选择部门信息!");// }else{// baseobj.getJsonData('/sendsms/userinfo',base.postdata,function(data){// console.log(data);// if(data.Status==1){// base.SendeeMsg=data.ResultDataInfos;// }else{// baseobj.layerobj.alertmsg("立即执行失败!")// }// // });// }// }, //发送短息 sendMsg:function(){//console.log(base.postdata) base.postdata.inf_account='thapp'; base.postdata.inf_token='123qwe!@#'; //base.postdata.recid=base.postdata.; base.postdata.send_user_account=''; if(base.postdata.dept_id==undefined){ baseobj.layerobj.alertmsg("请选择部门信息!") }else{ base.postdata.id=base.postdata.dept_id; console.log("下面要调接口") } } } }); return Foo;});
效果如下:
点击接收人,把上面部门的id传到下个页面:
完整代码下载地址:点击这里
阅读全文
0 0
- vue页面带参跳转(用requirejs进行模块化)
- requireJs进行模块化开发
- 模块化JS(RequireJS SeaJS)
- js模块化加载(requirejs)
- 模块化构建工具(requirejs)
- 模块化--RequireJS
- vue.js中利用router进行跳转(子页面刷新404问题)
- Flex中模块化页面跳转
- vue 点击传参 页面跳转
- vue-router跳转页面
- vue-router跳转页面
- vue页面跳转
- 用requirejs把ionic项目模块化
- CommonJs和AMD(requireJS)模块化
- 页面带参跳转及取值
- 页面跳转效果(系统自带)
- vue路由带参跳转,刷新后参数不消失
- vue页面跳转参数传递
- oracle_学习中的实用小技巧
- hdu 4489 The King’s Ups and Downs 组合 递推
- 二次元的进阶之旅
- 查看python是32位的还是64位的
- JSP
- vue页面带参跳转(用requirejs进行模块化)
- angular的$router的api使用
- EF的分析
- Web 高效开发必备的 PHP 框架
- Java中的24种设计模式与7大原则
- jsp入门
- bzoj1433(沈阳day7训练赛)
- webForm里面写mvc
- Leetcode练习<十二> 判断整数是否为回文