<template>
<div class="sale-share-box">
<span class="sale-share-btn">
<van-popover class="sale-share-btn-pop"
style=" width: 104px;
height: 82px;
background: #FFFFFF;
box-shadow: 0px 0px 6px 0px rgba(153, 153, 153, 0.3);
border-radius: 8px;"
v-model:show="showPopover"
placement="top">
<div class="sale-share-bid" v-if="!isOnSale" @click="setClick()" value='bid'>Bid</div>
<div class="sale-share-sell" v-if="isOnSale" @click="setClick()" value='sell'>Sell</div>
<div class="sale-share-transfer" @click="setClick()" value='transfer'>Transfer</div>
<!-- <router-link class="sale-share-bid" v-if="isOnSale" :to="{path:'this.url?#saleOrbid'}">Bid</router-link>
<router-link class="sale-share-sell" v-if="isOnSale" :to="{path:'/myself?#transfer'}" >Sell</router-link>
<router-link class="sale-share-transfer" to="/myself" >Transfer</router-link> -->
<template #reference>
<img @click="showPop(id)" src="../../assets/create-img/icon_more.png" />
</template>
</van-popover>
</span>
</div>
</template>
<script>
export default {
props:{
showPopover: {
type:Boolean,
default:false
},
isOnSale: {
type:Boolean,
default:false
},
goodId: {
type:[Number, String],
default:0
}
}, methods: {
showPop() {
//this.showPopover = true;
this.$emit('showPop', this.goodId);
},
setClick(){
var url = '/myself/' + this.goodId ;
window.location.href = url;
}
}
}
</script>
<style lang="less" >
.sale-share-bid{
cursor: pointer;
}
.sale-share-sell{
cursor: pointer;
}
.sale-share-transfer{
cursor: pointer;
}
</style>
<style lang="less" >
.sale-share-btn-pop .van-popover__content{
display: flex;
flex-direction:column;
width: inherit;
height: inherit;
// align-items: center;
padding-left: 10px;
justify-content: space-around; }
</style>

一、

(1)在/Users/mac/nft/pc/src/components/目录下创建sections/SalePopover.vue(组件名称)

(2)组件代码:

<template>
  <div class="sale-share-box">
  <span class="sale-share-btn">
  <van-popover class="sale-share-btn-pop"
      style="width: 104px;
      height: 82px;
      background: #FFFFFF;
      box-shadow: 0px 0px 6px 0px rgba(153, 153, 153, 0.3);
      border-radius: 8px;"
      v-model:show="showPopover"
      placement="top">
  <router-link class="sale-share-bid" v-if="!isOnSale" to="/myself">Bid</router-link>
  <router-link class="sale-share-sell" v-if="isOnSale" to="/myself" >Sell</router-link>
  <router-link class="sale-share-transfer" to="/myself" >Transfer</router-link>
  <template #reference>
    <img @click="showPop(id)" src="../../assets/create-img/icon_more.png" />
  </template>
  </van-popover>
  </span>
</div>
</template>
<script>
export default {
  props:{
    showPopover: {
    type:Boolean,
    default:false
  },
  isOnSale: {
    type:Boolean,
    default:false
  },
  goodId: {
    type:[Number, String],
    default:0
  }
},
methods: {
  showPop() {
  //this.showPopover = true;
  this.$emit('showPop', this.goodId);
  }
  }
}
</script>
三、在script中引入
import SalePopover from '../../components/sections/SalePopover.vue'
四、在vue<script>中

export default {
  name: 'Items',
  components: {
    SalePopover //引用组件
  },
}
五、template中具体使用方法
<sale-popover :isOnSale="item.good.isOnSale" :goodId="item.good.id" @showPop="itempopClick"></sale-popover>
六、在method中写:
methods:{
itempopClick(e){
  console.log(e);
  this.showPopover1 = e;
},
七、效果图

vue-封装组件-结合vant实现点击按钮弹出泡泡(Popover)事件控制多个泡泡出现时,弹出对应的泡泡的更多相关文章

  1. vue封装组件的正确方式-封装类似elementui的组件

    最近读了下element的源码,仿照他封装了两种不同的组件. 第一种:通过组件来调用显示的 <template> <!--src/component/custom/main.vue- ...

  2. vue 封装组件

    props 接收数据 props对象里面 键值 是对改数据的 数据类型 的规定.做了规范,使用者就只能传输指定类型的数据,否则报警告 先根据要求写出完整的代码,再一一用参数实现组件封装 这里试着封装一 ...

  3. vue 封装组件上传img

    var _uploadTemplate = '<div>'+ '<input type="file" name="file" v-on:cha ...

  4. Vue.js组件间通信方式总结

    平时在使用Vue框架的业务开发中,组件不仅仅要把模板的内容进行复用,更重要的是组件之间要进行通信.组件之间通信分为三种:父-子:子-父:跨级组件通信.下面,就组件间如何通信做一些总结. 1.父组件到子 ...

  5. 从零开始学 Web 之 Vue.js(六)Vue的组件

    大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...

  6. VB.Net中点击按钮(Button)会重复提交两次表单

    在VB.NET程序开发过程中遇到一个问题 提交一个表单时,button的html代码如下 <asp:Button ID="btnSubmit" OnClick="c ...

  7. vue封装公用弹出框方法,实现点击出现操作弹出框

    vue封装公用弹出框方法,实现点击出现操作弹出框 如上图所示,这次要实现一个点击出现操作弹框的效果:并将这个功能封装成一个函数,便于在项目的多个地方使用. 具体思路是: 封装一个组件,组件保护一个插槽 ...

  8. Vue 爬坑之路(九)—— 用正确的姿势封装组件

    迄今为止做的最大的 Vue 项目终于提交测试,天天加班的日子终于告一段落... 在开发过程中,结合 Vue 组件化的特性,开发通用组件是很基础且重要的工作 通用组件必须具备高性能.低耦合的特性 为了满 ...

  9. seventBus(封装) 一个巧妙的解决vue同级组件通讯的思路

    如果在你项目中需要多处用到同级组件通讯,而又不想去写繁琐的vuex,可以参考这个小思路.本人在写项目中琢磨出来的,感觉挺好用,分享一下. 1.在utils文件夹下添加BusEvent.js 注释已经很 ...

  10. vue脚手架中使用Vant,实现自动按需引入组件,并将px转换为rem

    偶然间看到一款不错的移动端vue组件库Vant,照着官方文档敲了一下,感觉还是不错的.想着以后的项目中可能会运用到,特此记录下,方便之后使用. 现在很多的组件库为了减小代码包体积,都支持按需加载了.V ...

随机推荐

  1. 一周ppt 总结

    最近写了一篇培训ppt ,大概花了7个工作日,走了一些弯路,问题总结: 开始一项工作前,对接清除核心要点(刚开网上搜罗一圈 拼凑了一份(将各个内容进行筛选整理) 反馈后不是领导想要的) 制作ppt前, ...

  2. dev随笔记录

    gridcontrolbandedGridviewPrintHeader = false(不显示列头)#region 勾选框全选或反选 List<string> islockList = ...

  3. python缩小放大浏览器

    driver.execute_script("document.body.style.zoom='70%'") driver.execute_script("docume ...

  4. Rinetd linxu TCP 端口转发

    Rinetd是为在一个Unix和Linux操作系统中为重定向传输控制协议(TCP)连接的一个工具,实现端口映射/转发/重定向.Rinetd是单一过程的服务器,它处理任何数量的连接到在配置文件etc/r ...

  5. (K8s学习笔记六)Pod的调度

    RC(ReplicationController)只能选择一个标签,RS(ReplicaSet)可选择多个标签,例如APPTest发布了v1和v2两个版本,并希望副本数为3,可同时包含v1和v2两个版 ...

  6. VSCode-WSL配置 C++ —— 以OpenCV4为例

    生成并编辑c_cpp_properties.json 命令窗口输入:>C/C++: Edit Configurations(JSON),就会自动生成该文件 在includePath中加上需要in ...

  7. 修改Linux终端默认编辑器,实现代码高亮

    echo export EDITOR=vim >>/etc/profile.d/env.sh

  8. gorm去重查询 iris框架

    写练习 demo 时遇到需要进行去重查询,gorm没有db.distinct()的写法 // 数据库的表字段 type Pro_location_relation struct { Id int64 ...

  9. 记一次mysql5.7保存Emoji表情

    1.错误:SQLException; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x90\x96 \ ...

  10. CxImageJPG

    typedef struct tag_ExifInfo { char Version [5]; //EXIF 信息版本 char CameraMake [32]; //DC 制造商 char Came ...