作者介绍:
本人Java特工,代号:Cris Li ; 中文名:克瑞斯理
简书地址: https://www.jianshu.com/u/c508b0afaaee
CSDN地址: https://blog.csdn.net/jianli95
个人纯洁版博客: https://lijian69.github.io/blog/
最终的项目图,如图所示:
这里只是附加代码和功能;具体需要有一些基础Vue基础的人
一、搜索相关的功能点
input 获得焦点触发事件、和失去焦点触发事件、异步查询事件,页面的展示事件、
<template>
<div class="search-panel">
<el-row class="m-header-searchbar">
<el-col
:span="3"
class="left">
<img
src="//s0.meituan.net/bs/fe-web-meituan/e5eeaef/img/logo.png"
alt="美团">
</el-col>
<el-col
:span="15"
class="center">
<div class="wrapper">
<el-input
v-model="search"
placeholder="搜索商家或地点"
@focus="focus"
@blur="blur"
@input="input"/>
<button class="el-button el-button--primary"><i class="el-icon-search"/></button>
<dl
v-if="isHotPlace"
class="hotPlace">
<dt>热门搜索</dt>
<dd
v-for="(item,idx) in hotPlace"
:key="idx">
<a :href="'/products?keyword='+encodeURIComponent(item.name)">{{ item.name }}</a>
</dd>
</dl>
<dl
v-if="isSearchList"
class="searchList">
<dd
v-for="(item,idx) in searchList"
:key="idx">
<a :href="'/products?keyword='+encodeURIComponent(item)">{{ item }}</a>
</dd>
</dl>
</div>
<p class="suggest">
<a
v-for="(item,idx) in hotPlace"
:key="idx"
:href="'/products?keyword='+encodeURIComponent(item)">{{ item }}</a>
</p>
<ul class="nav">
<li><nuxt-link
to="/"
class="takeout">美团外卖</nuxt-link></li>
<li><nuxt-link
to="/"
class="movie">猫眼电影</nuxt-link></li>
<li><nuxt-link
to="/"
class="hotel">美团酒店</nuxt-link></li>
<li><nuxt-link
to="/"
class="apartment">民宿/公寓</nuxt-link></li>
<li><nuxt-link
to="/"
class="business">商家入驻</nuxt-link></li>
</ul>
</el-col>
<el-col
:span="6"
class="right">
<ul class="security">
<li><i class="refund"/><p class="txt">随时退</p></li>
<li><i class="single"/><p class="txt">不满意免单</p></li>
<li><i class="overdue"/><p class="txt">过期退</p></li>
</ul>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
data() {
return {
isFocus:false,
search:null,
hotPlace:["火锅","火锅1","火锅2","火锅3","火锅4"],
searchList:["故宫","颐和园"]
}
},
computed:{
isHotPlace:function () {
return this.isFocus && !this.search;
},
isSearchList:function(){
return this.isFocus && this.search;
}
},
methods:{
focus:function(){
this.isFocus = true;
},
blur:function () {
var that = this;
// 延时方式点击时 点击不了
that._timer = setTimeout(function (params) {
that.isFocus = false;
},200);
//如果让延时无效 可以使用
//clearTimeout(that._timer)
},
input:function(){
console.log("input");
}
}
}
</script>
<style lang="scss">
</style>
选择自定义模板
前面章节已经提起到Layouts目录下存放的是页面的自定义模板,如果想使用现在Layouts目录下自定义一个模板vue文件,如下所示
<template>
<div class="layout-blank">
<nuxt /> //这里存放你的二级页面
</div>
</template>
<script>
export default {
}
</script>
二级页面如何向自定义模板中塞进去
<template>
<div>
1
</div>
</template>
<script>
export default {
layout:'blank' //这里选择该页面应该塞到那个模板中
}
</script>