我菜鸡一个,网上找了半天没找到问的公司大佬解决的,直接上代码
父组件:
<van-search v-bind="$attrs" class="ysearch" v-model="searchValue" shape="round" :placeholder="placeholder" background="none">
<!-- 搜索框左图标 -->
<template v-slot:left-icon>
<slot name="leftsvg"></slot>
</template>
<!-- 搜索框左图标 -->
<template v-slot:right-icon>
<slot name="rightsvg"></slot>
</template>
</van-search>
子组件:
<y-11search class="y-11search" v-bind="$attrs" @onSearch="handSearch">
<!-- 搜索框左图标 -->
<template v-slot:leftsvg>
<svg-icon class="search-lsvg" name="search" color="#C1C1C1" @click="handSearch"></svg-icon>///这里要注意下是不是注册使用的这个方法<svg-icon>
</template>
<!-- 搜索框右图标 -->
<template v-slot:rightsvg>
<svg-icon class="search-rsvg" name="search copy 2" color="#6B6B6C"></svg-icon>
</template>
</y-11search>