这里使用到vue的自界说指令
- <div class="item" v-clickoutside="clickoutside1">
- <div @click="opencity" class="text"
- :style="{ color: popup.iscitypop || okcitylist.length != 0 ? '#FF9500' : '#000000' }">选择地区
- </div>
- <i v-if="popup.iscitypop || okcitylist.length != 0" class=" el-icon-arrow-up"
- :style="{ color: popup.iscitypop || okcitylist.length != 0 ? '#FF9500' : '#000000' }"></i>
- <i v-else class="el-icon-arrow-down"
- :style="{ color: popup.iscitypop || okcitylist.length != 0 ? '#FF9500' : '#000000' }"></i>
- //绝对定位样式 popup.iscitypop true展示 false隐藏
- <div class="poppad" v-if="popup.iscitypop">
- <div class="tit" v-for="(item, index) in citylist" :key="index">
- {{ item.n }}
- <div class="cit">
- <div class="items" :class="its.isactive ? 'active' : ''" v-for="(its, ind) in item.s" :key="ind"
- @click.stop="changeCity(its, ind)">
- {{ its.n }}
- </div>
- </div>
- </div>
- </div>
- </div>
- export default {
- directives: {
- clickoutside: {
- bind: function (el, binding, vnode) {
- function documentHandler(e) {
- if (el.contains(e.target)) {
- return false;
- }
- if (binding.expression) {
- binding.value(e);
- }
- }
- el.__vueClickOutside__ = documentHandler;
- document.addEventListener("click", documentHandler);
- },
- unbind: function (el, binding) {
- document.removeEventListener("click", el.__vueClickOutside__);
- delete el.__vueClickOutside__;
- }
- }
- },
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |