比如下面是我自定义的按钮
<template>
<view >
<!-- <view class="w-100 " style="height: 80rpx;"> -->
<view class="btn-fa">
<button type="primary " class="btn ma0 d-flex a-center j-center ">
<slot >为我推荐</slot>
</button>
</view>
<!-- </view> -->
</view>
</template>
<script>
</script>
<style>
.btn{
width: 592rpx;
height: 80rpx;
background: rgba(0, 122, 255, 0.05);
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.15);
border-radius: 8rpx;
border: 2rpx solid #007AFF;
font-size: 32rpx;
color: #007AFF;
}
.btn-fa button::after{
border: none;
}
</style>
在别的页面上用了这个组件 添加点击事件 @click = “” 失效
在@click后面加native表示的是当前页面的事件
<btn @click.native="lala"></btn>
methods: {
lala(){
console.log('sdasd')
}
}