<template>
<div id="show-blog">
<Scroll class="sccon" ref="scroll">
<h3>博客总览</h3>
<input type="text" placeholder="搜索" v-model="search" />
<div class="single-blog" v-for="item in blog" :key="item.title">
<h2 v-rainbow>{{ item.title | to-uppercase | snippet }}</h2>
<article>{{ item.content | snippet }}</article>
</div>
</Scroll>
<tool-bar ref="tool"></tool-bar>
</div>
</template>
Scroll是我封装的better-scroll组件,tool-bar是侧边栏,侧边栏代码如下,希望监听第三个”回到首页“的组件,在此组件点击的时候,可以获得Scroll组件的scroll对象(此对象是betterscroll实例的方法)其中的scrollTop方法
<template>//此代码为tool-bar的代码
<side-bar>
<side-bar-item>
<div slot="side-icon-active">客服</div>
</side-bar-item>
<side-bar-item>
<div slot="side-icon-active">分享</div>
</side-bar-item>
<side-bar-item @click.native="backClick()">
<div slot="side-icon-active">回到<br />首页</div>
</side-bar-item>
</side-bar>
</template>