vue 搜索框header_vue项目header模块编写

前端学习的太差了,一个header写了半天才写个勉强能用的。

vue-cli引入scss

npm install node-sass --savenpm install sass-loader --save

从element-ui官方拷贝一个导航栏修改

处理中心我的工作台选项1选项2选项3选项4选项1选项2选项3订单管理

css样式完善

/*顶部导航栏盒子*/.myHeader {  /** 导航栏固定在顶部*/  .headBack{    width: 100%;    background: rgba(40,52,44,0.6);    box-shadow: 0 2px 4px rgba(0,0,0,0.2);    position: fixed;    left: 0;    top: 0;    z-index: 100;  }  .headBox .el-menu {    background: transparent;    border-bottom: none!important;  }  .headBox .el-menu-demo li.el-menu-item,  .headBox .el-menu--horizontal .el-submenu .el-submenu__title {    height: 38px;    line-height: 38px;    border-bottom: none!important;  }  //导航栏字体修改  .headBox .el-submenu div.el-submenu__title{    color: #fff;  }  .el-menu--horizontal >ul ,  .headBox>ul li.el-menu-item:hover,  .headBox>ul li.el-submenu:hover .el-submenu__title,  .headBox ul .el-submenu .el-menu .el-menu-item ,  .headBox .el-menu--horizontal.menu  ul{    background: #48456C;    border-bottom: none;    box-shadow: 0 0 0px 0 rgba(0, 0, 0, 0.1) !important;  }  // 如果展开颜色显示和下拉列表一致  .is-opened{    background: #48456C !important;  }  // 菜单右边  .userInfo{    position: absolute;    right: 30px;    color: #ffffff;    line-height: 38px;  }   .userInfo a {    color: #fff;    font-size: 13px;    transition: all 0.2s ease-out;  }  .headBox .userInfo a:hover {    color: #48456C;  }  .pcsearchbox{    max-width: 170px;    height: 100%;    line-height: 38px;    position: absolute;    top: 0;    right: 0;    cursor: pointer;  }  /*pc搜索框*/  .headBox .pcsearchbox {    padding: 0;    max-width: 170px;    /*min-width: 30px;*/    height: 100%;    line-height: 38px;    position: absolute;    top: 0;    right: 0;    cursor: pointer;  }  .headBox .pcsearchbox:hover .pcsearchinput {    opacity: 1;    /*transform: scaleX(1);*/    visibility: visible;  }  .headBox .pcsearchbox i.pcsearchicon {    color: #fff;    padding-left: 10px;  }  .headBox .pcsearchbox .pcsearchinput {    width: 180px;    padding: 10px 20px 10px 20px;    background: rgba(40, 42, 44, 0.6);    border-radius: 0 0 2px 2px;    position: absolute;    right: 0;    top: 38px;    opacity: 0;    visibility: hidden;    /*transform: scaleX(0);*/    transform-origin: right;    transition: all 0.5s ease-out;  }  .headBox .pcsearchbox .hasSearched {    opacity: 1;    /*transform: scaleX(1);*/    visibility: visible;  }  .headBox .pcsearchbox .el-input {    width: 100%;  }  .headBox .el-input__inner {    height: 30px;    border: none;    background: #fff;    /*border: 1px solid #333;*/    border-radius: 2px;    padding-right: 10px;  }}/*下拉选项菜单*/.el-menu--horizontal .el-menu .el-menu-item,.el-menu--horizontal .el-menu .el-submenu__title {  background-color: #64609E !important;  float: none;  height: 36px;  line-height: 36px;  color: #909399;  position: relative;}//  下拉菜单body > div.el-menu--horizontal.menu > ul{  list-style: none;  position: relative;  margin: 0;  z-index: 100;  min-width: 130px;  border: none;  padding:  0;  border-radius: 2px;  box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.1);}body > div.el-menu--horizontal.menu > ul > li:hover {  background: #48456C !important;}

修改后的页面

处理中心我的工作台选项1选项2选项3订单管理
登录 | 注册
个人中心 喜欢列表 收藏列表 退出登录

效果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用element-ui的el-table组件和el-input组件来实现表格搜索框。具体实现步骤如下: 1. 在el-table中添加一个slot="header"的template,用于放置搜索框。 2. 在template中添加一个el-input组件,用于输入搜索关键字。 3. 在el-table的data属性中添加一个filterText属性,用于存储搜索关键字。 4. 在el-table的computed属性中添加一个filteredData属性,用于根据搜索关键字过滤数据。 5. 在el-input的v-model属性中绑定filterText,实现搜索框与数据的双向绑定。 示例代码如下: ``` <template> <div> <el-table :data="tableData" style="width: 100%"> <el-table-column prop="name" label="姓名"></el-table-column> <el-table-column prop="age" label="年龄"></el-table-column> <el-table-column prop="address" label="地址"></el-table-column> <template slot="header"> <el-input v-model="filterText" placeholder="请输入搜索关键字"></el-input> </template> </el-table> </div> </template> <script> export default { data() { return { tableData: [ { name: '张三', age: 18, address: '北京市' }, { name: '李四', age: 20, address: '上海市' }, { name: '王五', age: 22, address: '广州市' }, { name: '赵六', age: 24, address: '深圳市' } ], filterText: '' } }, computed: { filteredData() { return this.tableData.filter(item => { return item.name.toLowerCase().includes(this.filterText.toLowerCase()) || item.address.toLowerCase().includes(this.filterText.toLowerCase()) }) } } } </script> <style> </style> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值