vue select的change事件,将点击过的城市名存在数组中,下次调用不需要再调用接口
<template>
<div id="body" class="application" v-show="show" v-cloak>
<div class="applicationForm">
<div class="essentialInformation">
<ul>
<li>
<div class="agencyNamjian fr">
<img src="../assets/img/xiala.png" width="100%" height="100%" />
</div>
<div class="agencyName agencyJantou">
<span class="plaseCity" v-show="plaseCityShow" v-text="plaseProvinceText"></span>
<select v-model='provinceSelect' @change ="cityChange(1)">
<option v-for="(item,index) in application.province" :key="index" :value="item.id" v-text="item.title"></option>
</select>
</div>
</li>
<li>
<div class="agencyNamjian fr">
<img src="../assets/img/xiala.png" width="100%" height="100%" />
</div>
<div class="agencyName agencyJantou">
<span class="plaseCity" v-show="plaseCityShow" v-text="plaseCityText"></span>
<select v-model="citySelect" @change="cityChange(2)">
<option v-for="(item,index) in city" :key="index" :value="item.id" v-text="item.title"></option>
</select>
</div>
</li>
<li>
<div class="agencyNamjian fr ">
<img src="../assets/img/xiala.png" width="100%" height="100%" />
</div>
<div class="agencyName agencyJantou noBorder">
<span class="plaseCity" v-show="plaseCityShow" v-text="plaseCountyText"></span>
<select v-model="countySelect">
<option v-for="(item,index) in county" :key="index" :value="item.id" v-text="item.title"></option>
</select>
</div>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'application',
data () {
return {
show: false,
application: {
province: [],
city: {},
county: {}
},
city: [],
county: [],
provinceSelect: '',
citySelect: '',
countySelect: '',
tishi: false,
tishiTxt: '',
plaseCityShow: true,
plaseCityText: '请子选择城市',
plaseProvinceText: '请选择城市',
plaseCountyText: '请选择(区)县'
}
},
methods: {
verify: function () {
let thisObj = this
this.$chaos.setTitle('报名表单')
this.$chaos.verify(function () {
thisObj.$chaos.ajax({
data: {
pid: '0'
},
slient: true,
userinfo: true,
url: 'get_address_by_pid',
callback: function (type, res) {
if (type !== 'success') {
return
}
if (res.status) {
thisObj.application.province = res.info.region_list
thisObj.show = true
} else {
thisObj.$vux.toast.show({
text: res.msg,
type: 'text',
position: 'bottom'
})
}
}
})
thisObj.$chaos.ajax({
slient: true,
userinfo: true,
url: 'user_is_sign',
callback: function (type, res) {
if (type !== 'success') {
return
}
if (res.status) {
let userInfo = thisObj.$chaos.getUserInfo()
if (userInfo.user_info.is_sign === 1) {
window.location.href = '#/CourseList'
} else {
userInfo.user_info.is_buy_course = 1
thisObj.$chaos.setUserInfo(userInfo)
}
} else {
thisObj.$vux.toast.show({
text: res.msg,
type: 'text',
position: 'bottom'
})
}
}
})
}, false)
},
cityChange: function (type) {
let thisObj = this
if (type === 1) {
if (thisObj.provinceSelect === '' || typeof thisObj.provinceSelect === 'undefined') {
return
}
if (typeof thisObj.application.city[thisObj.provinceSelect] === 'undefined') {
thisObj.plaseCityShow = false
thisObj.$chaos.ajax({
data: {
pid: thisObj.provinceSelect
},
slient: true,
userinfo: true,
url: 'Attend/get_address_by_pid',
callback: function (type, res) {
if (type !== 'success') {
return
}
if (res.status) {
thisObj.application.city[thisObj.provinceSelect] = res.info.region_list
thisObj.city = res.info.region_list
thisObj.citySelect = thisObj.city[0]['id']
} else {
thisObj.$vux.toast.show({
text: res.msg,
type: 'text',
position: 'bottom'
})
}
}
})
} else {
thisObj.city = thisObj.application.city[thisObj.provinceSelect]
thisObj.citySelect = thisObj.city[0]['id']
}
} else {
if (thisObj.city === '' || typeof thisObj.city === 'undefined') {
return
} else {
if (typeof thisObj.application.county[thisObj.city] === 'undefined') {
thisObj.$chaos.ajax({
data: {
pid: thisObj.citySelect
},
slient: true,
userinfo: true,
url: 'Attend/get_address_by_pid',
callback: function (type, res) {
if (type !== 'success') {
return
}
if (res.status) {
thisObj.application.county[thisObj.citySelect] = res.info.region_list
thisObj.county = res.info.region_list
thisObj.countySelect = thisObj.county[0]['id']
} else {
thisObj.$vux.toast.show({
text: res.msg,
type: 'text',
position: 'bottom'
})
}
}
})
} else {
thisObj.county = thisObj.application.county[thisObj.citySelect]
thisObj.countySelect = thisObj.county[0]['id']
}
}
}
}
},
created: function () {
this.verify()
},
watch: {
'$route': 'verify'
}
}
</script>
<style scoped>
[v-cloak] {
display: none;
}
.plaseCity{
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
line-height: 55px;
text-indent: 10px;
}
.essentialInformation, .importaInformation {
background: #FFFFFF;
}
.essentialInformation {
margin: 10px 0;
}
.essentialInformation ul, .importaInformation ul {
margin: 0 15px;
}
.agencyNameImg {
width: 20px;
height: 20px;
line-height: 4.3;
}
.fl {
float: left;
}
.noBorder {
border: 0;
}
.essentialInformation:after {
content: '';
display: block;
clear: both;
}
.agencyNamjian {
width: 11px;
height: 8px;
line-height: 4.3;
}
.agencyJantou {
padding-right: 40px;
position: relative;
}
.agencyName {
margin-left: 30px;
border-bottom: 1px solid #cccccc;
line-height: 3.8
}
.essentialInformation input, .essentialInformation select {
width: 100%;
text-indent: 10px;
border: 0;
-webkit-appearance: none;
background: transparent;
}
.essentialInformation select {
height: 55px;
position: relative;
z-index: 0;
}
.agencyBut {
margin-top: 100px;
}
.squadButton {
text-align: center;
color: #fff;
background: #fbac36;
margin: 0 30px;
line-height: 2.5;
font-size: 16px;
box-shadow: 0px 1px 5px #ccc;
}
.agencyBut {
margin-top: 100px;
} </style>
vue select的change事件,将点击过的城市名存在数组中,下次调用不需要再调用接口的更多相关文章
- vue select框change事件
vue Select 中< :label-in-value="true" @on-change="satusSelect"> satusSelect ...
- 关于element-ui select组件change事件只要数据变化就会触发的解决办法
使用select组件和表格组件结合起来用,但是发现在点击下一页的时候,由于select当中的数据发生了变化,所以也会触发select当中的change事件,但是我只希望在我主动改变select组件当中 ...
- jquery 怎么触发select的change事件
可以使用jQuery的trigger() 方法来响应事件 定义和用法 trigger() 方法触发被选元素的指定事件类型. 语法 $(selector).trigger(event,[param1,p ...
- elementUI下拉框select组件change事件用法
<el-select-custom clearable collapse-tags v-model="searchForm.cardTypeList" @change=&qu ...
- js改变select的选中项不触发select的change事件
// test var selectEl = document.querySelector('select') var buttonEl = document.querySelector('butto ...
- layui中select的change事件、动态追加option
说明:layui中用jquery 中的选择器例如$('#id').change(function(){})发现不起作用 layui操作:lay-felter标识操作哪个select html部分: & ...
- jquery操作select标签change事件
$('#update_supply_id').on('change',function(){//判断是否选取prompt属性,无返回值: if($(this).val()){ var selectTe ...
- (转载)Unity 关于动态监听时,点击Button,返回其在数组中的下标
其实是绕了一圈,把数组里的元素放进数组列表里再读取它的下标 using System.Collections; using System.Collections.Generic; using Unit ...
- select控件自动触发change事件
这里接上面的二级联动.背景:当页面跳转到修改页面时,需要首先绑定学院和专业.这就需要在页面加载时触发select的change事件,具体用trigger函数进行实现.代码如下. $("#xs ...
随机推荐
- 碎碎念android eMMC【转】
本文转载自:https://blog.csdn.net/Fybon/article/details/44242549 一./dev/blockroot@:/dev/block #ls bootdevi ...
- C# 基于任务的异步模式的创建与使用的简单示例
对于窗体程序,使用基于任务的异步模式需要用到Task类,下面示例下非常简单的用法. 1.创建一个拥有异步方法的类 该类拥有一个异步方法DoSomthingAsync,根据微软建议的命名规则该方法要带A ...
- bzoj 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 最小点覆盖
链接 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 思路 这就是个上一篇的稍微麻烦版(是变脸版,其实没麻烦) 用边长为1的模板覆盖地图上的没有长草的土地,不能覆盖草地 ...
- 比原链设计思考: 扩展性UTXO模型
用户模型是比原链在最初就需要确定的重要数据结构, 团队的选择还是聚焦在两种典型的模型系统中,Account模型和UTXO模型,和其他大多数区块链设计一样, 选择了模型就决定了协议层的重要实现,两种模型 ...
- SQLite EF Core Database Provider
原文链接 This database provider allows Entity Framework Core to be used with SQLite. The provider is mai ...
- js实现类型jq的dom加载完成
有时候我们只想在 dom 加载完成后运行 js ,而不是等所有图片加载完成.所以不需要 onload , onload 会加载图片等其他媒体.很消耗时间. 原:http://blog.csdn.net ...
- 1st,Python基础——01
1 Python介绍 2 Python发展史 3 Python2 or 3? 4 Python安装 就不写了,各路大牛的博客都很详细. 5 Hello World程序 #!/usr/bin/env p ...
- Android打开相机进行人脸识别,使用虹软人脸识别引擎
上一张效果图,渣画质,能看就好 功能说明: 人脸识别使用的是虹软的FreeSDK,包含人脸追踪,人脸检测,人脸识别,年龄.性别检测功能,其中本demo只使用了FT和FR(人脸追踪和人脸识别),封装了开 ...
- 学习笔记57—归一化 (Normalization)、标准化 (Standardization)和中心化/零均值化 (Zero-centered)
1 概念 归一化:1)把数据变成(0,1)或者(1,1)之间的小数.主要是为了数据处理方便提出来的,把数据映射到0-1范围之内处理,更加便捷快速.2)把有量纲表达式变成无量纲表达式,便于不同单位或 ...
- Ajax请求导出Excel的问题
文章转载自: http://yuwenlin.iteye.com/blog/2275289 Ajax请求导出Excel的问题描述: 前端发起Ajax请求get或post,后台使用Poi生成excel文 ...