Vue实现选择城市功能(2)

watch: { citySearch: function (newCitySearch) { //citySearch是input中输入的值 this.cityFilter(newCitySearch) } cityFilter: function (city) { // 城市搜索筛选 let showCityListTemp this.buildItem(cityNamesFilter) showCity = showCityTemp showCity = showCity.filter(function (value) { showCityList = value.citylist showCityListTemp = showCityList.filter(function (val) { return (val.indexOf(city) > -1) }) value.citylist = showCityListTemp return value.citylist.length > 0 }) this.showCity = showCity if (showCity.length === 0) { let _showCityContent = document.getElementById('showCityContent') _showCityContent.innerText = '查询不到结果' _showCityContent.setAttribute('class', 'tipShow') } else { document.getElementById('showCityContent').innerText = '' } }

到这里,基本的的城市算是做完了。

查看完整的代码请到   我的github地址  https://github.com/qianyinghuanmie/vue2.0-demos

以上所述是小编给大家介绍的Vue实现选择城市功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wysyzg.html